Repository navigation
Conversation
Update `config.yaml` to the changed configuration of FOCA 0.14: - server: remove `environment` and `use_reloader`; disable debug mode, which allows executing arbitrary code. - security.auth: trust the LS Login issuer (`issuers` is required, or all tokens are rejected), and remove `validation_methods` and `validation_checks` (signatures are always verified locally). The audience is not validated yet (`verify_audience: false`). - exceptions: `exceptions` is renamed to `mapping`; the other members are removed. - api.specs: paths are relative to the config file, not the working directory. - ID charset: expressions are no longer evaluated; use the characters. Remove the `string` imports that the expression needed, and adapt the tests and docstrings. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
- Require FOCA 0.14 and Connexion 2.15.1 or later (FOCA's lower bound). - Base the image on the current FOCA image, which runs as non-root user and no longer ships build tools, curl or jq: install the app as root, add curl and jq (needed by `update-config-map.sh`), then switch back. Drop `chmod g+w` of the API directory; FOCA no longer writes modified specifications. - Use MongoDB 8.0 in the compose file: the PyMongo version that FOCA 0.14 requires needs MongoDB 4.4 or later. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Reviewer's GuideUpgrades the service from FOCA 0.12.1 to 0.14.0 across configuration, application models, authentication, dependencies, container packaging, tests, and local MongoDB infrastructure. Review deployment-specific issuer/audience settings, config-relative specification paths, non-root container behavior, and the required upgrade path for existing MongoDB data. Sequence diagram for FOCA token validationsequenceDiagram
participant Client
participant Registry
participant FOCA
participant LSLogin
Client->>Registry: HTTP request with bearer token
Registry->>FOCA: Validate token
FOCA->>FOCA: Verify RS256 signature locally
FOCA->>FOCA: Check issuers
FOCA->>FOCA: Skip audience check
FOCA-->>Registry: Accept or reject token
Registry-->>Client: API response
Note over FOCA: Trusted issuer: https://login.aai.lifescience-ri.eu/oidc/
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
MongoDB 8.0 refuses to start on Linux kernels 6.19 to 7.0.13 (SERVER-121912), which recent hosts and GitHub runners have. Also describe how deployments should set the token audience. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #65 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 6 6
Lines 214 223 +9
=========================================
+ Hits 214 223 +9 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
* build: bump mypy to 2.4.0
mypy 0.971 can no longer parse the type stubs of current MarkupSafe
releases ("Positional-only parameters are only supported in Python 3.8
and greater"), so the static code analysis job fails on a fresh
install. mypy 2.4.0 reports no issues on cloud_registry.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
* build: pin setuptools below 82
FOCA 0.12 imports pkg_resources without declaring setuptools as a
dependency, and setuptools 82 removed pkg_resources. Python 3.10
environments happen to ship an older setuptools; Python 3.12 venvs
have none, so the tests could not even be collected there. Remove the
pin with the upgrade to FOCA 0.14 (#65), which no longer imports it.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
* ci: fail on Codecov errors only on pushes
Pull requests from forks and Dependabot get no access to the Codecov
token, so the upload with fail_ci_if_error always failed there and
turned "Run tests" red. Fail on upload errors only on pushes, and
upgrade codecov-action from v3 to v7.1.1 (pinned by commit).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
* ci: run tests on Python 3.10 and 3.12
The Docker image uses Python 3.12 (FOCA base image), while CI tested
only 3.10. Upload coverage once, from the 3.12 run.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
* ci: harden workflow, retry smoke test
- Upgrade checkout and setup-python, pin all actions by commit and
drop docker/setup-compose-action (Compose v2 is preinstalled).
- Restrict the token to read access and do not persist credentials.
- Cancel superseded pull request runs; give push runs their own
concurrency group, so queued runs for successive pushes are kept.
- Cache pip downloads and set job timeouts.
- Move the Docker Compose smoke test into its own job, poll the app
for up to 2 minutes instead of sleeping 30 seconds, and print the
Compose logs on failure.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
* ci: keep Run tests check, publish newest only
- Add an aggregate "Run tests" job that passes only if all matrix test
jobs passed, so required status checks that name "Run tests" keep
working after the switch to a Python version matrix.
- Serialize the publish job per branch and skip it when the commit is
no longer the branch head, so that an older run finishing last cannot
overwrite the `latest` image with older code.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---------
Co-authored-by: Claude Opus 5.5 <[email protected]>
* build: fix package metadata and contents - Add a [build-system] table and requires-python >= 3.10; classifiers for Python 3.10 to 3.12 instead of 3.8. - Use an SPDX license expression instead of the deprecated license table and classifier. - Package only cloud_registry (the wheel also contained top-level `docs` and `tests` packages) and include its config and API specs in the wheel. A non-editable install still cannot run the app: config.yaml refers to modules relative to cloud_registry/, and FOCA 0.12 resolves spec paths against the working directory and writes modified specs next to them (see #74). - Remove the dynamic version (the file it points to does not exist) and the unused dynamic optional dependencies; fix black's `line-length` key. Co-Authored-By: Claude Opus 5.5 <[email protected]> * build: drop yq from runtime requirements The Python package does not use yq; only update-config-map.sh (Helm config job, #67) calls the yq CLI, which the Dockerfile installs separately. Pin it there to the version previously required. Co-Authored-By: Claude Opus 5.5 <[email protected]> * build(deps): bump dev dependencies black 26.10.1, coverage 7.16.2, flake8 7.4.1, Flake8-pyproject 1.2.4, mongomock 4.3.0, pytest 9.1.1. Add build 1.6.1; CI now builds the distributions and checks that the wheel contains only cloud_registry with its config and API specs. Supersedes #55 and #57; no code changes needed. Co-Authored-By: Claude Opus 5.5 <[email protected]> * ci: add Dependabot configuration Monthly updates for pip, GitHub Actions and the Docker base image, one grouped PR per ecosystem. connexion and foca get individual PRs; connexion major updates (need a FOCA upgrade) and setuptools (capped until #65) are ignored. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
* fix: draw a new service ID on each retry POST /services retried an insert after a duplicate key error, but generated the identifier only once, so a collision returned 500 after ten identical attempts. Generate a new identifier on every attempt. Also stop modifying the caller's request data: RegisterService now works on a copy, and inserts a copy so that pymongo's `_id` does not leak into it. The test for running out of identifiers never configured the one-character ID space it meant to set up; it now does, against an in-memory collection with a unique index. Fixes #72 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix: return service-info status as an integer postServiceInfo returned the status code as the string "201". connexion logs the status with "%d" at debug level, which fails for a string: logging prints a traceback, and wherever logging errors are raised (e.g. under pytest), the request ends in a 500. Co-Authored-By: Claude Opus 5.5 <[email protected]> * test: add app-level tests with shared fixtures Add tests/conftest.py with an app created from config.yaml, MongoDB replaced by mongomock and the identity provider by a mock that issues and checks RS256 tokens. The fixtures work with FOCA 0.12 (flask_pymongo) and 0.14 (pymongo), so the same tests can verify the upgrade in #65. tests/test_app.py sends requests through the API, covering every endpoint: success paths, an empty database, PUT create vs. replace, 404s, schema validation (400), missing or invalid tokens (401) and the error response format. It also tests app.py's main(), which is no longer omitted from coverage. The app still fetches remote references in the GA4GH specs at startup, so these tests need network access until #76. Closes #32, closes #40 Part of #71 Co-Authored-By: Claude Opus 5.5 <[email protected]> * test: use shared fixtures in unit tests Replace the app and in-memory collection set up by hand in almost every unit test with the `unit_app`, `services` and `service_info` fixtures. The collections now have the unique indexes from config.yaml, so duplicate identifiers behave as in production. Tests that replaced the collection with a MagicMock now use the in-memory collection and also check what was stored. The MagicMock duplicate-key test is dropped; the duplicate-key retry test covers it against a real unique index. Closes #71 Co-Authored-By: Claude Opus 5.5 <[email protected]> * test: exclude main guard from coverage Now that app.py is measured, its `if __name__ == "__main__":` guard is the only line not covered, which made Codecov report a drop in project coverage. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
Resolve conflicts: FOCA 0.14 requirements without yq and the setuptools cap; the FOCA image's Dockerfile with yq pinned as on dev; dev's tests. Also drop the Dependabot ignore for setuptools, which was only capped until this upgrade. Co-Authored-By: Claude Opus 5.5 <[email protected]>
FOCA 0.14 types `log_traffic` as returning `Callable`, so mypy 2.4 (bumped on dev) rejects the `__wrapped__` access in getServiceTypes. The call goes away with the `distinct` query planned in #74. Co-Authored-By: Claude Opus 5.5 <[email protected]>
elixircloud/foca:20261019-py3.12 contains a FOCA 0.14 pre-release, so every build installed FOCA 0.14.0 from PyPI on top of it. The 0.14.0-py3.12 tag contains the release. Co-Authored-By: Claude Opus 5.5 <[email protected]>
FOCA 0.14 no longer evaluates expressions such as 'string.digits' as the character set for generated identifiers, and raises an error instead. A config still using one loaded fine, and every POST /services then failed with a 500. Validate the character set when the config is loaded, so that such a config fails at startup. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
FOCA 0.14 uses pydantic 2, which deprecates `dict()`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Like charset expressions, a length of 0 or less loaded fine and made every POST /services fail with a 500. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Hey - I've found 4 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="cloud_registry/config.yaml" line_range="34" />
<code_context>
+ # the user logged in with (e.g., the registry's front end, a portal
+ # or a gateway), so set `audience` to their client IDs and remove
+ # `verify_audience`.
+ verify_audience: False
# Database configuration
</code_context>
<issue_to_address>
**Other-client tokens access protected endpoints**
When the Helm deployment uses the repository config and a caller presents a valid LS Login token for a different client, `verify_audience: False` lets FOCA accept the token without checking its `aud` claim. The configmap Job copies this config without setting an audience, so the token can reach bearer-protected endpoints, including service creation, replacement, and deletion.
Configure the expected client IDs as audiences and stop disabling audience verification.
</issue_to_address>
### Comment 2
<location path="docker-compose.yaml" line_range="18" />
<code_context>
- image: mongo:3.6
+ # MongoDB 8.0 refuses to start on Linux kernels 6.19 to 7.0.13
+ # (https://jira.mongodb.org/browse/SERVER-121912)
+ image: mongo:7.0
restart: unless-stopped
volumes:
</code_context>
<issue_to_address>
**Existing database stays unavailable**
When a Compose deployment starts with a data volume created by MongoDB 3.6, compose starts MongoDB 7.0 directly against the existing data files, which cannot be upgraded directly from MongoDB 3.6. The database container stays down and the registry cannot access its existing service records.
Upgrade the data volume through the required intermediate MongoDB versions before switching Compose to MongoDB 7.0.
</issue_to_address>
### Comment 3
<location path="Dockerfile" line_range="2" />
<code_context>
##### BASE IMAGE #####
-FROM elixircloud/foca:20240711-py3.12
+FROM elixircloud/foca:0.14.0-py3.12
##### METADATA #####
</code_context>
<issue_to_address>
**Default chart installs keep old image**
When a user installs the Helm chart with its default image value, `deployment/values.yaml` still selects `elixircloud/cloud-registry:20240716`, so the Deployment and configmap Job use the previously published app image. Changing the Dockerfile base image does not upgrade a default Helm installation.
Update the chart’s default image value to the image built with FOCA 0.14.
</issue_to_address>
### Comment 4
<location path="cloud_registry/config.yaml" line_range="98" />
<code_context>
- required_members: [['detail'], ['status'], ['title']]
- status_member: ['status']
- exceptions: cloud_registry.exceptions.exceptions
+ mapping: cloud_registry.exceptions.exceptions
custom:
</code_context>
<issue_to_address>
**Error media type contradicts the spec**
When a caller validates error response Content-Type against the published OpenAPI spec, fOCA 0.14 returns error responses as `application/problem+json`, but the referenced OpenAPI responses still declare `application/json` (for example, `cloud_registry/api/20201108.e0358db.openapi.yaml:124-154`). Strict clients and generated clients that follow the declared media type see a contract mismatch on errors.
Update the error response media types in the OpenAPI specs or configure the handlers to return the declared media type.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 4 findings to address first, and with verify_audience: False, tokens from the configured issuer are accepted regardless of which application they were issued for, so a token intended for another client could grant access to the registry. Reverting stops future acceptance but cannot undo access or data exposure that already occurred.
Blocking findings: cloud_registry/config.yaml:34, docker-compose.yaml:18, Dockerfile:2, cloud_registry/config.yaml:98
Upgrade from FOCA 0.12.1 to 0.14.0 and adapt the config, code, image, Compose setup and tests. Squashed from #65, whose first commits are unsigned and therefore cannot be merged under the signed-commit rule. - config: trust LS Login as issuer, `verify_audience: False`, rename `exceptions` to `mapping`, spec paths relative to the config, spell out the ID charset (validated when the config is loaded), no debug - code: pydantic 2 `model_dump()` - build: `foca>=0.14.0,<0.15`, base image `elixircloud/foca:0.14.0-py3.12` with `curl` and `jq`, MongoDB 7.0 in Compose - tests: drop FOCA 0.12 compatibility, test the custom config models BREAKING CHANGE: custom configs must apply the FOCA 0.14 config changes, and existing MongoDB 3.6 data needs a stepwise upgrade to 7.0. Co-authored-by: Alex Kanitz <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Summary
Upgrade from FOCA 0.12.1 to FOCA 0.14.0 (released 2026-10-20).
Changes
config.yaml:server:environmentanduse_reloaderare removed.debugis nowFalse, since FOCA warns that debug mode with host0.0.0.0allows executing arbitrary code.security.auth:issuersis required (without it, all tokens are rejected) and is set to LS Login.validation_methodsandvalidation_checksare removed; signatures are always verified locally.audience: nullbecomesverify_audience: False, because FOCA now requires either an audience or this explicit opt-out.exceptions:exceptionsis renamed tomapping;required_membersandstatus_memberare removed. The existing mapping already has the requiredstatusandtitlemembers.api.specs[].path: now relative to the config file (api/...instead ofcloud_registry/api/...). This also holds for the deployed config, which the Helm chart mounts next to the module.charset: expressions are no longer evaluated, so the characters are spelled out. A config that still uses an expression (or a length below 1) now fails when it is loaded, not on every POST/services.Code:
model_dump()instead of pydantic 1'sdict().type: ignorefor the__wrapped__call ingetServiceTypes; the call goes away with Refactor: remove duplicated and unused code #74.Build:
requirements.txt:foca>=0.14.0,<0.15andconnexion>=2.15.1,<3, without thesetuptoolscap (FOCA 0.14 no longer usespkg_resources). The Dependabot ignore forsetuptoolsis dropped.Dockerfile:elixircloud/foca:0.14.0-py3.12. The FOCA image runs as a non-root user and has no build tools,curlorjq.curlandjqare added (the Helm configmap Job runsupdate-config-map.shfrom this image), and then the user is switched back.chmod g+wofcloud_registry/apiis removed: FOCA no longer writes modified specifications.docker-compose.yaml: MongoDB 3.6 → 7.0. The PyMongo version that FOCA 0.14 needs requires MongoDB 4.4 or later, and MongoDB 8.0 refuses to start on Linux kernels 6.19 to 7.0.13 (SERVER-121912).Verification
pytest(70 passed),flake8,black --check .andmypy cloud_registrypass. No pydantic deprecation warnings from our code.config.yamlvalidates against the FOCA 0.14 config models.0.14.0-py3.12base image and MongoDB 7.0.Not verified: a real MongoDB, and real LS Login tokens (so whether their
audclaim is usable is still unknown).Decisions and deployment notes
https://login.aai.lifescience-ri.eu/oidc/). This matches the group mapping that access control (Cloud Registry backend: public read access, service ownership, ECP_CLN:ADMIN admin role #62, feat!: add owner-based access control #66) is built on. Other identity providers can be added toissuerswhen needed.audto the client ID of the app the user logged in with. The repository config keepsverify_audience: False(e.g., for local development). Deployments should setaudienceto the client IDs of the apps calling the registry (front end, portal, gateway) and removeverify_audience.featureCompatibilityVersionin between). This also applies to the local Compose volume../data/cloud-registry/db. Pinning the Helm chart's MongoDB image (currentlymongo:noble, i.e. 8.x) is part of Deployment: pin MongoDB, add DB auth, probes #68.config.yamlchanges above; FOCA rejects the removed keys at startup.Not changed
update-config-map.shsets.endpoints.service.*at the root of the config instead of.custom.endpoints.service.*. Both FOCA versions accept the stray key, so the intended override of external host and port has never taken effect. Fixing it would change deployed behavior; it belongs with the config rework in Helm chart: configure app via values and FOCA overlays #67.application/json, while FOCA now responds withapplication/problem+json. Error handlers are not covered by response validation, so nothing breaks.stringconstants intests/test_app.py(an independent check).🤖 Generated with Claude Code
Summary by Sourcery
Upgrade the Cloud Registry to FOCA 0.14 and align its configuration, authentication, runtime image, dependencies, database, and tests with the new release.
Bug Fixes:
Enhancements:
Build:
Deployment:
Tests:
Chores: