Repository navigation
feat!: move API additions to camelCase - #353
Conversation
Fields and query parameters that the registry adds to the GA4GH specs, and the names it stores in MongoDB, are now camelCase, like the specs they extend. Config keys stay snake_case. Additions to the service info are grouped under `registrationRules`. There is no migration: going from 1.0.0-rc1 needs a fresh database. On such data the app refuses to start and says so. Startup code that only served data of earlier versions is gone, and so is the upgrade test. Closes #352 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Refuse old indexes and services without keys, also in dry runs. Remove dead code and docs of the removed startup steps; stored services in tests have the internal fields of real ones. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Name indexes in the refusal, document it for dry runs, describe startup steps by what still causes them, and store the smoke test's service with its key and creator. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideThis breaking release consistently moves registry-added API and MongoDB names to camelCase, adds early refusal of legacy data/index formats with no migration path, removes obsolete legacy-repair startup behavior, and updates documentation, deployment guidance, smoke checks, and tests accordingly. Sequence diagram for startup validation of the database formatsequenceDiagram
participant App
participant MongoDB
participant FOCA
App->>MongoDB: index_information()
App->>MongoDB: find_one(old-format query)
alt legacy data or index found
MongoDB-->>App: legacy format detected
App-->>App: refuse_old_format()
else current format
MongoDB-->>App: no legacy data or index
App->>FOCA: create_app()
FOCA-->>App: application started
end
Flow diagram for camelCase API and storage format changeflowchart LR
Client[API client] --> API[camelCase API fields and query parameters]
API --> Store[camelCase MongoDB fields and indexes]
Store --> Fresh[Fresh database required]
Legacy[Earlier snake_case data or indexes] --> Refuse["refuse_old_format()"]
Refuse --> Stop[No migration; application stops]
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #353 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 23 23
Lines 2625 2572 -53
=========================================
- Hits 2625 2572 -53 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="cloud_registry/ga4gh/registry/locks.py" line_range="67" />
<code_context>
Filter of locks that started at or before `stale_before()`.
"""
- return {"started_at": {"$lte": stale_before()}}
+ return {"startedAt": {"$lte": stale_before()}}
</code_context>
<issue_to_address>
**Interrupted renames stay blocked**
When a database retains a pre-rc2 interrupted rename lock with `started_at` and no other detected legacy marker, `stale()` matches only `startedAt`, so `resume_renames()` skips the legacy lock; `lock_exclusive()` then encounters its existing `_id` and returns `None`, leaving the interrupted rename unrecovered and operations on the affected service busy.
Make stale-lock recovery handle legacy `started_at` locks, and have `refuse_old_format()` detect legacy `service_locks` fields and indexes.
Also at `cloud_registry/utils.py:28-40`.
</issue_to_address>
### Comment 2
<location path="cloud_registry/ga4gh/registry/service.py" line_range="665" />
<code_context>
- continue
try:
- check_url_scheme(url, schemes=schemes)
+ check_url_scheme(service["url"], schemes=schemes)
except InvalidService:
ids.append(f"'{service['id']}'")
</code_context>
<issue_to_address>
**Malformed service data blocks startup**
When a stored service has no URL or a non-string URL, `warn_url_schemes()` passes the stored URL directly to `check_url_scheme()`, which calls `.strip()`; a missing URL raises `KeyError` and a non-string URL raises `AttributeError`. The exception aborts app startup instead of letting the registry serve other services.
Validate that the stored URL is a string before checking its scheme, and skip or log malformed values without aborting startup.
</issue_to_address>Linked issues
#352 Move all API additions to camelCase · 6 of 7 met
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | Move registry-added API fields and query parameters to camelCase, without prefixes. | ✅ Met | The OpenAPI schemas, handlers, documentation, and tests use the renamed API fields and the includeAccepted query parameter. |
| 2 | Keep additions to spec objects camelCase, grouped under one key and to a minimum. | ✅ Met | Registration rules are served under registrationRules with camelCase rule fields. |
| 3 | Store registry-added MongoDB fields and indexes in camelCase, using the same names as the API. | ✅ Met | The changed stored fields and configured indexes use camelCase names. |
| 4 | Keep config keys snake_case, Python code PEP 8, and error code values unchanged. | ✅ Met | The configuration references remain snake_case, while the API-facing renames do not change Python identifiers or error codes. |
| 5 | Require a fresh database without migration, document the upgrade, and refuse old-format data or indexes at startup. | 🟡 Partly met | The fresh-database requirement is documented and startup checks refuse several old-format collections, but they do not check legacy service_locks data or indexes. |
| 6 | Remove obsolete indexes and startup code made unnecessary by the format change. | ✅ Met | The obsolete service repair and warning routines are removed, and the _serviceKey index is no longer sparse. |
| 7 | Add a short API style section and update the OpenAPI additions, documentation, and tests. | ✅ Met | The API style section and corresponding specification, documentation, and test updates are present. |
Sourcery assessment
Needs a human reviewer. 2 findings to address first, and existing deployments cannot start against the old stored format, and the documented upgrade path requires an empty database and re-registering data; the app itself refuses to start rather than deleting that data. Reverting can restore access if the old database was retained, but new-format writes and the API renames also require compatible versions of the app and clients.
Blocking findings: cloud_registry/ga4gh/registry/locks.py:67, cloud_registry/ga4gh/registry/service.py:665
Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Linked issues
#352 Move all API additions to camelCase · 7 of 8 met
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | Move registry-added API fields and query parameters to camelCase without aliases. | ✅ Met | The API schema, handlers, smoke checks, and tests use the new names. |
| 2 | Keep service-info additions camelCase, grouped under one key, and document the API style. | ✅ Met | The extension is grouped under registrationRules, and docs/api.md adds an API style section. |
| 3 | Store registry-added MongoDB fields in camelCase, using the same names as the API where applicable. | ✅ Met | The stored fields and their queries are updated; the specified internal service fields remain unchanged. |
| 4 | Rename MongoDB indexes to use the new camelCase fields. | ✅ Met | The configured index fields and names use camelCase. |
| 5 | Keep config keys snake_case, Python code PEP 8, and error code values unchanged. | ✅ Met | The config continues to use snake_case and Python identifiers remain snake_case. |
| 6 | Require a fresh database without migration and document the upgrade in docs/upgrading.md and docs/releases/1.0.0rc2.md. |
✅ Met | Both documents state that data is not kept and a fresh database is required. |
| 7 | Refuse old-format databases at startup by detecting old data or indexes. | 🟡 Partly met | The refusal checks known old fields and indexes, but does not check the old compound lock index service_1_started_at_1. |
| 8 | Remove obsolete indexes and startup code made unnecessary by the fresh-database requirement. | ✅ Met | The sparse service-key index and the specified old-data startup steps are removed. |
Summary
Moves everything the registry adds to the GA4GH specs to camelCase: API fields, query parameters, what is stored in MongoDB and its indexes, with the same names. Upstream Service Info and Service Registry are camelCase, so additions follow the spec they extend. The full list of renames is in #352 and in
docs/upgrading.md.snake_case; Python stays PEP 8; errorcodevalues stay.registrationRules.docs/api.mdgets a short "API style" section.docs/upgrading.md,docs/releases/1.0.0rc2.mdanddeployment/README.md.refuse_old_format()stops the app (andnamespace_subjects --dry-run) on data or indexes of earlier versions, naming the collections.add_service_keys,warn_invalid_urls,warn_organization_fields,add_service_creators, the upgrade test and its captured data. The_serviceKeyindex is no longer sparse.Left as they are on purpose: collection names (config keys, e.g.
service_types) and underscore-prefixed internal service fields (_serviceKey,_pending,_createdBy,_selfEntry,_verifiedAt).The UI must follow:
cloud-registry-uiis not changed here.Closes #352
How it was verified
MONGODB_TEST_URI=<own MongoDB 7.0> coverage run -m pytestat f09d997: 2018 passed, 100% coverage. The later commit changes text, comments, a test helper name and the smoke fixture; affected tests rerun.pre-commit run --all-files(without gitleaks locally),mypy cloud_registry tests,mkdocs build --strict.refuse_old_format()on a private MongoDB 7.0: no collections, indexes just created by FOCA and a later start all pass; onlytoken_hash_1is refused.Declined review findings
urlfailwarn_url_schemes()at startup: only hand-edited documents can lack it.stored_service()(e.g.tests/test_service_types.py, racing inserts intests/test_rename.py): they don't reach the code that needs the internal fields, and raw documents are clearer for what they test.createdAtbranch inRegisterService: kept as a guard against hand-written documents; removing it is unrelated cleanup.namespace_subjects --dry-runrefusal is a traceback, noterror: ...: same message and exit status 1 as the refusal on startup.servicesand its sparse_serviceKey_1index passes the check: FOCA then stops startup with its index conflict error, so nothing runs on such data.🤖 Generated with Claude Code