Repository navigation
feat!: upgrade to FOCA 0.14.0 - #92
Conversation
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: Claude Opus 5.5 <[email protected]>
Reviewer's GuideThis PR upgrades Cloud Registry from FOCA 0.12.1 to 0.14.0 by migrating configuration and Pydantic APIs, tightening issuer/debug defaults, validating service ID settings at startup, updating the container and MongoDB runtime, and removing legacy compatibility code and fixtures. Sequence diagram for startup validation of service identifierssequenceDiagram
participant Config as IdConfig
participant Validator as field_validator
participant FOCA as generate_id
Config->>Validator: _check_charset(charset)
Validator->>FOCA: generate_id(charset, length=1)
alt charset is invalid
FOCA-->>Validator: TypeError
Validator-->>Config: ValueError
Config-->>Config: Reject configuration at startup
else charset is valid
FOCA-->>Validator: generated identifier
Validator-->>Config: Accept charset
end
Sequence diagram for trusted token issuer validationsequenceDiagram
actor Client
participant Registry as CloudRegistry
participant FOCA as FOCA 0.14
Client->>Registry: API request with token
Registry->>FOCA: Validate token issuer
alt issuer is LS Login
FOCA-->>Registry: Accept token
Registry-->>Client: Process request
else issuer is untrusted
FOCA-->>Registry: Reject token
Registry-->>Client: Authentication error
end
File-Level Changes
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 #92 +/- ##
=========================================
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:
|
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>
**Unrelated clients access registry**
When the checked-in config or default Helm deployment is used without an audience restriction and a caller presents a valid LS Login token issued to another client, `verify_audience: False` makes FOCA accept the token, and the caller can use its claims on authenticated registry endpoints to create, replace, or delete entries.
Set `audience` to the registry's client IDs and remove `verify_audience`.
</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 Compose database won't upgrade**
When an existing Compose volume contains MongoDB 3.6 data, `docker-compose.yaml` starts MongoDB 7.0 directly against the existing data directory; MongoDB does not support a direct 3.6-to-7.0 upgrade, so the database container fails to start and the local registry cannot use its stored data.
Provide or require the stepwise MongoDB upgrade before using the 7.0 image with an existing data volume.
</issue_to_address>
### Comment 3
<location path="cloud_registry/service_models/custom_config.py" line_range="240-242" />
<code_context>
+ def _check_charset(cls, charset: str) -> str:
+ """Reject character sets that identifiers cannot be generated from."""
+ try:
+ generate_id(charset=charset, length=1)
+ except TypeError as exc: # pydantic only reports `ValueError`s
+ raise ValueError(str(exc)) from exc
+ return charset
</code_context>
<issue_to_address>
**Legacy charsets produce unexpected IDs**
When a custom config retains a legacy expression such as `string.digits`, `IdConfig._check_charset` passes the expression text to `generate_id` as a literal character set, so the value passes validation and generated service IDs can contain its letters and punctuation instead of digits; startup does not reject the config.
Make `_check_charset` reject legacy expressions rather than validating their text as a literal character set.
</issue_to_address>
### Comment 4
<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>
**Helm defaults to the old image**
When a Helm install or upgrade uses the chart's default values without overriding `cloud_registry.image`, the Helm deployment and configmap job use `.Values.cloud_registry.image`, whose default remains `elixircloud/cloud-registry:20240716`; they therefore run the previously published image rather than the image built from this Dockerfile. Users installing or upgrading with default values do not get the FOCA upgrade.
Update the chart's default image tag to the newly published image, or otherwise ensure the default Helm deployment selects the image built from this Dockerfile.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 4 findings to address first, and the MongoDB Compose image jumps from 3.6 to 7.0 while reusing a persistent data volume; an incompatible on-disk upgrade could leave that data unavailable even after reverting the image, requiring a backup restore or migration. The FOCA config also changes issuer validation, so an unexpected token-validation change could disrupt authentication, but reverting would undo that runtime behavior.
Blocking findings: cloud_registry/config.yaml:34, docker-compose.yaml:18, cloud_registry/service_models/custom_config.py:242, Dockerfile:2
Supersedes #65 with the same tree, as one signed commit: the first commits of #65 are unsigned (committed with an unverified e-mail address), so the
required_signaturesrule blocks merging #65, even as a squash. Authorship is preserved.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.0 and adopt its updated configuration, authentication, dependency, container, and database requirements.
Bug Fixes:
Enhancements:
Build:
Deployment:
Tests:
Chores: