Skip to content

feat!: move API additions to camelCase - #353

Merged
uniqueg merged 4 commits into
devfrom
feat/camel-case
Nov 4, 2026
Merged

uniqueg merged 4 commits into
devfrom
feat/camel-case

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

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.

  • Config keys stay snake_case; Python stays PEP 8; error code values stay.
  • Additions to the service info stay grouped under registrationRules.
  • docs/api.md gets a short "API style" section.
  • No migration: 1.0.0-rc1 to rc2 needs a fresh database, stated in docs/upgrading.md, docs/releases/1.0.0rc2.md and deployment/README.md.
  • refuse_old_format() stops the app (and namespace_subjects --dry-run) on data or indexes of earlier versions, naming the collections.
  • Removed startup code for old data: add_service_keys, warn_invalid_urls, warn_organization_fields, add_service_creators, the upgrade test and its captured data. The _serviceKey index 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-ui is not changed here.

Closes #352

How it was verified

  • MONGODB_TEST_URI=<own MongoDB 7.0> coverage run -m pytest at 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.
  • Reviewer run: refuse_old_format() on a private MongoDB 7.0: no collections, indexes just created by FOCA and a later start all pass; only token_hash_1 is refused.
  • CI on 2842d43: all checks passed, including Test (MongoDB 7.0), Smoke test and Scan image; again on the last commit (see the checks below).

Declined review findings

  • Sourcery: stored services without a string url fail warn_url_schemes() at startup: only hand-edited documents can lack it.
  • Not every test insert uses stored_service() (e.g. tests/test_service_types.py, racing inserts in tests/test_rename.py): they don't reach the code that needs the internal fields, and raw documents are clearer for what they test.
  • Remaining wording such as "before timestamps were checked" and the invalid createdAt branch in RegisterService: kept as a guard against hand-written documents; removing it is unrelated cleanup.
  • namespace_subjects --dry-run refusal is a traceback, not error: ...: same message and exit status 1 as the refusal on startup.
  • A selective wipe that keeps services and its sparse _serviceKey_1 index passes the check: FOCA then stops startup with its index conflict error, so nothing runs on such data.

🤖 Generated with Claude Code

uniqueg and others added 3 commits November 4, 2026 01:45
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]>
@uniqueg uniqueg added this to the v1.0.0-rc2 milestone Nov 4, 2026
@sourcery-ai

sourcery-ai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

This 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 format

sequenceDiagram
    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
Loading

Flow diagram for camelCase API and storage format change

flowchart 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]
Loading

File-Level Changes

Change Details Files
Rename registry-added API fields, query parameters, service-info extensions, and persisted MongoDB fields/indexes from snake_case to camelCase while preserving configuration, Python, error-code, collection, and internal underscore-prefixed names.
  • Update OpenAPI schemas, handlers, service information, permissions, invitations, verifications, approvals, listings, locks, renames, and namespace migration logic.
  • Rename corresponding MongoDB fields and indexes, remove sparse handling for the service key index, and update fixtures, smoke checks, and integration/unit tests.
  • Document the API naming convention and complete breaking-change rename matrix for clients and operators.
cloud_registry/api/additions.openapi.yaml
cloud_registry/ga4gh/registry/invitations.py
cloud_registry/ga4gh/registry/locks.py
cloud_registry/ga4gh/registry/permissions.py
cloud_registry/ga4gh/registry/rename.py
cloud_registry/ga4gh/registry/self_listing.py
cloud_registry/ga4gh/registry/service_info.py
cloud_registry/ga4gh/registry/service_types.py
cloud_registry/ga4gh/registry/verification.py
cloud_registry/config.yaml
docs/api.md
docs/access-control.md
docs/configuration.md
docs/operations.md
tests
Make the storage-format change explicitly incompatible and reject pre-rc2 databases before application/index initialization.
  • Add refuse_old_format() checks for legacy documents and indexes, including dry-run namespace migration, with collection-specific errors.
  • Remove legacy startup repair and warning routines for keys, creators, invalid URLs, and organization fields; retain current configuration validation warnings and service-type synchronization.
  • Require a fresh database for upgrades and document backup, rollback, deployment, and client-update procedures.
cloud_registry/utils.py
cloud_registry/app.py
cloud_registry/namespace_subjects.py
cloud_registry/ga4gh/registry/service.py
cloud_registry/ga4gh/registry/service_limits.py
deployment/README.md
docs/upgrading.md
docs/releases/1.0.0rc2.md
tests/test_app.py
tests/test_namespace_subjects.py
tests/test_upgrade_rc1.py
tests/data/store_1.0.0rc1.json
Align verification coverage and deployment smoke tests with the new API and storage format.
  • Update smoke fixture documents, response assertions, index assertions, and test helpers to use camelCase persisted and served fields.
  • Remove obsolete rc1 capture/upgrade fixtures and tests while adding legacy-format refusal and new-format startup coverage.
.github/workflows/ci.yml
tests/conftest.py
tests/mock_data.py
tests/ga4gh/registry/test_server.py
tests/ga4gh/registry/test_service.py
tests/ga4gh/registry/test_service_info.py
tests/ga4gh/registry/test_verification.py
tests/test_access_control.py
tests/test_invitations.py
tests/test_issuers.py
tests/test_rename.py
tests/test_self_listing.py
tests/test_service_limits.py
tests/test_service_types.py
tests/test_verification.py

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov

codecov Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (558a912) to head (093cf58).
⚠️ Report is 1 commits behind head on dev.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@uniqueg
uniqueg marked this pull request as ready for review November 4, 2026 02:08

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread cloud_registry/ga4gh/registry/locks.py Resolved
Co-Authored-By: Claude Opus 5.5 <[email protected]>

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread cloud_registry/utils.py Resolved
@uniqueg
uniqueg merged commit a8b1d0e into dev Nov 4, 2026
39 of 44 checks passed
@uniqueg
uniqueg deleted the feat/camel-case branch November 4, 2026 02:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move all API additions to camelCase

1 participant