Skip to content

feat!: upgrade to FOCA 0.14.0 - #92

Merged
uniqueg merged 1 commit into
devfrom
feat/foca-0.14-signed
Oct 20, 2026
Merged

uniqueg merged 1 commit into
devfrom
feat/foca-0.14-signed

Conversation

@uniqueg

@uniqueg uniqueg commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

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_signatures rule 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: environment and use_reloader are removed. debug is now False, since FOCA warns that debug mode with host 0.0.0.0 allows executing arbitrary code.
  • security.auth:
    • issuers is required (without it, all tokens are rejected) and is set to LS Login.
    • validation_methods and validation_checks are removed; signatures are always verified locally.
    • audience: null becomes verify_audience: False, because FOCA now requires either an audience or this explicit opt-out.
  • exceptions: exceptions is renamed to mapping; required_members and status_member are removed. The existing mapping already has the required status and title members.
  • api.specs[].path: now relative to the config file (api/... instead of cloud_registry/api/...). This also holds for the deployed config, which the Helm chart mounts next to the module.
  • ID 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:

Build:

  • requirements.txt: foca>=0.14.0,<0.15 and connexion>=2.15.1,<3, without the setuptools cap (FOCA 0.14 no longer uses pkg_resources). The Dependabot ignore for setuptools is dropped.
  • Dockerfile:
    • Base image elixircloud/foca:0.14.0-py3.12. The FOCA image runs as a non-root user and has no build tools, curl or jq.
    • The app is installed as root, curl and jq are added (the Helm configmap Job runs update-config-map.sh from this image), and then the user is switched back.
    • chmod g+w of cloud_registry/api is 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).
  • Tests: the fixtures no longer support FOCA 0.12.

Verification

  • Python 3.10 and 3.12, FOCA 0.14.0 from PyPI: pytest (70 passed), flake8, black --check . and mypy cloud_registry pass. No pydantic deprecation warnings from our code.
  • The app-level tests from test: add app test harness, fix ID retry #90 run against FOCA 0.14 (they were written to pass on both versions). They cover every endpoint, tokens with a forged signature, and an untrusted issuer.
  • config.yaml validates against the FOCA 0.14 config models.
  • Reviewed by an adversarial and a maintainability review, 2 rounds each. Round 1 found the pre-release FOCA in the base image and the silently accepted charset expressions (both fixed).
  • CI (run 39365727193): all checks pass, including the Docker Compose smoke test with the 0.14.0-py3.12 base image and MongoDB 7.0.

Not verified: a real MongoDB, and real LS Login tokens (so whether their aud claim is usable is still unknown).

Decisions and deployment notes

  • Trusted issuer: only LS Login (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 to issuers when needed.
  • Audience: LS Login sets aud to the client ID of the app the user logged in with. The repository config keeps verify_audience: False (e.g., for local development). Deployments should set audience to the client IDs of the apps calling the registry (front end, portal, gateway) and remove verify_audience.
  • MongoDB data: existing MongoDB 3.6 data needs a stepwise upgrade (3.6 → 4.0 → 4.2 → 4.4 → 5.0 → 6.0 → 7.0, setting featureCompatibilityVersion in between). This also applies to the local Compose volume ../data/cloud-registry/db. Pinning the Helm chart's MongoDB image (currently mongo:noble, i.e. 8.x) is part of Deployment: pin MongoDB, add DB auth, probes #68.
  • Custom configs: deployments with their own config must apply the config.yaml changes above; FOCA rejects the removed keys at startup.

Not changed

🤖 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:

  • Validate service identifier character sets and lengths when configuration is loaded.

Enhancements:

  • Upgrade the application to FOCA 0.14 and align configuration, authentication, exception handling, and Pydantic usage with the new release.

Build:

  • Update the FOCA and Connexion dependencies, use the FOCA 0.14 Python 3.12 base image, install required image utilities, and upgrade the Compose MongoDB service to 7.0.

Deployment:

  • Update the container and local database configuration for FOCA 0.14 compatibility.

Tests:

  • Update test fixtures for FOCA 0.14 and add coverage for invalid service identifier configuration.

Chores:

  • Remove the obsolete setuptools dependency constraint and legacy FOCA compatibility code.

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]>
@sourcery-ai

sourcery-ai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

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

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

Sequence diagram for trusted token issuer validation

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

File-Level Changes

Change Details Files
Align the application configuration and authentication behavior with FOCA 0.14.
  • Disable unsafe debug mode and remove obsolete server settings.
  • Configure LS Login as the trusted issuer and adopt local signature verification with explicit audience opt-out.
  • Rename exception configuration, update relative API specification paths, and replace evaluated ID character expressions with validated literal character sets.
  • Use Pydantic 2 serialization APIs and add a mypy exception for the temporary wrapped call.
cloud_registry/config.yaml
cloud_registry/ga4gh/registry/server.py
cloud_registry/ga4gh/registry/service.py
cloud_registry/ga4gh/registry/service_info.py
cloud_registry/service_models/custom_config.py
tests/test_app.py
Upgrade dependencies and container/runtime integration for FOCA 0.14.
  • Pin the FOCA 0.14-compatible dependency ranges and remove the obsolete setuptools constraint.
  • Adopt the FOCA 0.14 Python 3.12 base image, install deployment-script tools as root, then run the application as UID 1000.
  • Remove the obsolete API write-permission workaround.
  • Upgrade the local MongoDB service from 3.6 to 7.0 and adjust Dependabot configuration.
requirements.txt
Dockerfile
docker-compose.yaml
.github/dependabot.yml
Remove FOCA 0.12 compatibility from test infrastructure and expand configuration validation coverage.
  • Simplify MongoDB mocking and authentication-cache handling for FOCA 0.14.
  • Update mock configuration to use literal ID character sets.
  • Add tests covering accepted and invalid character sets and non-positive identifier lengths.
tests/conftest.py
tests/mock_data.py
tests/service_models/__init__.py
tests/service_models/test_custom_config.py

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 Oct 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (c94bd8e) to head (878d975).

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.
📢 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 October 20, 2026 03:53

@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 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


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

Comment thread cloud_registry/config.yaml Resolved
Comment thread docker-compose.yaml Resolved
Comment thread Dockerfile Resolved
@uniqueg
uniqueg merged commit d373f94 into dev Oct 20, 2026
10 checks passed
@uniqueg
uniqueg deleted the feat/foca-0.14-signed branch October 20, 2026 03:58
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.

1 participant