Report the backend and API version from /status, renaming the Solr index version to index_version - #304
Open
gaurav wants to merge 2 commits into
Open
Report the backend and API version from /status, renaming the Solr index version to index_version#304gaurav wants to merge 2 commits into
/status, renaming the Solr index version to index_version#304gaurav wants to merge 2 commits into
Conversation
Adds two keys to /status, matching NodeNorm (NCATSTranslator/NodeNormalization#392): - backend: always "solr" here. The Elasticsearch-backed NameRes at biothings/NameResolutionAPI reports "elasticsearch". Until now the two differed only by a word of prose in `message`, so nothing machine-readable said which implementation answered -- which is what blocked TranslatorSRI/babel-validation from pinning a NameRes target to its expected backend the way it already does for NodeNorm. - version: the OpenAPI info.version verbatim, so a caller can tell when the API changed without fetching /openapi.json, and so NameRes and NodeNorm spell it the same way. `version` was already taken by the Solr index version, which is renamed to `index_version`. This is a breaking change for anyone reading the Solr index version out of /status. The keys both branches share are now built once as `common` and spread into each return, so the error branch ("Expected core not found.") cannot drift from the ok branch. That branch is what a mis-pointed or still-loading deployment returns, and is exactly when a caller most needs to know which NameRes it reached. test_status.py pins `version` against /openapi.json's info.version rather than a literal, so the identity between the two is actually tested and the assertion survives version bumps. Closes #296. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
API.md describes `backend`, `version` and `index_version`, and calls out that `index_version` was `version` before v1.8.0. Also refreshes the stale nameres_version in the example, which still said v1.5.1. The CLAUDE.md gotcha records why `version` means the API version here and not the Solr index version, and why both branches of status() have to report `backend`. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #296.
Breaking change:
/status'sversionis now the API version/statusalready had a top-levelversion— the Solr index version ("version": 34838). NodeNorm usesversionfor the frontend version, and the point of this change is that the two services can be checked the same way, soversionhas been handed to the API version and the Solr index version is now reported asindex_version.Anyone reading the Solr index version out of
/statusneeds to follow the rename. Nothing in this repo did.What
Two keys, matching NodeNorm's
/status(NCATSTranslator/NodeNormalization#392, issue NCATSTranslator/NodeNormalization#377):backend"solr"here"elasticsearch". Until now the two deployments differed only by a word of prose inmessage("...primary core."vs"...primary index."), so nothing machine-readable said which implementation answered.versioninfo.versionverbatim ("1.7.0")/openapi.json, under the same key NodeNorm uses.nameres_version("v1.7.0", thev-prefixed spelling) is unchanged, for consumers that already read it.{ "status": "ok", "message": "Reporting results from primary core.", "backend": "solr", "version": "1.7.0", ... "nameres_version": "v1.7.0", ... "index_version": 34838, "segmentCount": 57 }Decisions and gotchas
versioncomes fromget_app_info(), notapp.openapi_schema. NodeNorm's version of this readapp.openapi_schema["info"]["version"]; here that attribute isNoneuntil the first request to/openapi.json(see theapp.openapigotcha in CLAUDE.md, Restore the x-translator, contact and termsOfService OpenAPI metadata dropped by FastAPI 0.137.0 #294), so/statuswould report"unknown"on a fresh process.status()already calledget_app_info(), which reads the sameopenapi.ymlthe served spec is built from.status()reportbackendandversion. The error branch (Expected core not found.) is what a mis-pointed or still-loading deployment returns, and is exactly when a caller most needs to know which NameRes it reached. To make divergence impossible rather than merely intended, the shared keys are now built once ascommonand spread into each return.versionagainst the served spec, not a literal.tests/test_status.pyassertsstatus['version'] == client.get("/openapi.json").json()['info']['version'], so the identity between the two is actually tested and the assertion doesn't need editing on every version bump.tests/test_openapi.pyasserted nothing aboutinfo.versionbefore this.Follow-on work
api/resources/openapi.ymlis still at1.7.0. The API.md note saysindex_versionwasversion"before NameRes v1.8.0" (this issue's milestone), so bump it when the release is cut.releases/stops atv1.5.2and has no 1.6/1.7 entries.Tests
python -m pytest tests/— 53 passed against a local Solr with the 89-doc test index. The error branch was verified by hand against a mocked two-core Solr response (so the single-core fallback doesn't rescue it); it carriesbackendandversion.🤖 Generated with Claude Code