Skip to content

refactor!: use the shared FOCA 0.18 features #226

Closed

Description

@uniqueg

Blocked by the FOCA 0.18.0 release (no release issue to link as a dependency).

Cloud Registry, the template for FOCA apps, has its own code for things that FOCA 0.18 now provides for all apps, moved there from this repo: the Gunicorn settings (elixir-cloud-aai/foca#458, elixir-cloud-aai/foca#463), the startup checks of the config (elixir-cloud-aai/foca#459, elixir-cloud-aai/foca#466), the public URL and typed custom config (elixir-cloud-aai/foca#460, elixir-cloud-aai/foca#465), and request-specific problem details, including those of validation errors (elixir-cloud-aai/foca#461, elixir-cloud-aai/foca#464). Keeping both copies means two implementations to maintain, and apps that copy Cloud Registry copy code they no longer need.

Upgrade to FOCA 0.18 (foca>=0.18.0,<0.19), use its features, and delete the copies here. Besides what was merged, FOCA has decided (in progress) to make group_mapping without claim_groups and a group claim with surrounding whitespace startup errors, to turn exceptions.validation_details on by default, to remove get_enforcer() (in favour of locked_enforcer()), and to use a Gunicorn keep-alive of 100 s (also in the foca-common chart); this issue follows the released behaviour.

What changes

Gunicorn settings

  • Dockerfile: CMD ["gunicorn", "--config", "python:foca.gunicorn_config", "cloud_registry.app:create_app()"] (comment and module docstring of cloud_registry/app.py updated).
  • Delete cloud_registry/gunicorn_config.py, tests/test_gunicorn_config.py and its entry in docs/reference.md; keep only the test that the image's command matches its health check (port), and tests/gunicorn_settings.py as far as tests/test_chart.py still needs it (test_gunicorn_defaults, test_gunicorn_values, adapted to the chart's new keep-alive default).
  • docs/configuration.md ("Gunicorn") links to FOCA's settings ("Running in production" in FOCA's deployment docs) instead of listing its own; overrides via GUNICORN_CMD_ARGS and cloudRegistry.gunicorn are unchanged. gunicorn stays a runtime dependency (the image runs it).

Startup checks (cloud_registry/app.py, cloud_registry/ga4gh/registry/permissions.py)

  • Set security.access_control.require_admin: true in cloud_registry/config.yaml (false in config.dev.yaml); delete check_admin_groups(), AccessControlConfig and custom.access_control (CustomConfig.access_control).
  • Replace check_no_service_clients() with foca.security.auth.require_no_service_clients(app.app) in create_app().
  • Delete warn_placeholder_service_info(), PLACEHOLDER_ID and PLACEHOLDER_ORGANIZATION; FOCA's check_service_info() warns of org.example.cloud-registry and https://example.org without configuration.
  • Keep the app's own checks (server.max_content_length not null, add_service_keys(), warn_invalid_urls(), warn_url_schemes()).
  • Chart (deployment/templates/_helpers.tpl, cloud-registry.validate): read config.security.access_control.require_admin instead of config.custom.access_control.require_admin (default true, as the base config), and fail with an upgrade hint if config.custom.access_control is still set, as for the other removed custom keys. The chart's checks of claim_groups stay (they mirror FOCA's, now errors there too).
  • tests/test_access_control.py: replace get_enforcer() (imported from foca.security.access_control.enforcement, used once) with locked_enforcer(). cloud_registry/ga4gh/registry/permissions.py itself has no get_enforcer() calls on dev; check again when this is implemented.

Public URL and typed custom config (cloud_registry/utils.py)

  • Replace custom.endpoints.service (url_prefix, external_host, external_port, api_path) with FOCA's server.public_url; delete ServiceConfig and EndpointsConfig.service from cloud_registry/service_models/custom_config.py.
  • Delete get_public_url() and _format_host(); server.py uses foca.utils.urls.get_public_url(path) for the Location header of POST /services.
  • Delete get_custom_config(); callers (permissions.py, service.py) use foca.get_custom_config(CustomConfig).
  • FOCA raises RuntimeError on the first POST /services if server.public_url is not set, so create_app() refuses to start without it, as for server.max_content_length (the base config leaves it unset; config.dev.yaml sets http://localhost:8080).
  • Chart: hostName sets server.public_url to https://<hostName> (instead of custom.endpoints.service); a new optional value publicUrl (camelCase, as Helm's conventions and the chart's other keys) overrides it, e.g., for a path prefix of a proxy, and is added to values.yaml, values.schema.json and deployment/README.md. Rendering fails with an upgrade hint if config.custom.endpoints.service is still set.

Problem details (cloud_registry/exceptions.py, cloud_registry/app.py)

  • Set exceptions.validation_details: true in cloud_registry/config.yaml (also explicit once it is FOCA's default; exceptions.max_detail_length keeps FOCA's default of 500, as MAX_DETAIL_LENGTH here).
  • Delete validation_problem(), problem(), _response(), _mapped(), shorten_detail() and MAX_DETAIL_LENGTH, and in create_app() the handler registrations for BadRequestProblem/ExtraParameterProblem, the logger setting and VALIDATION_LOGGER. FOCA filters Connexion's request validation log records instead of raising its logger to CRITICAL, so response validation errors are still logged. Keep the mapping exceptions.
  • Callers use foca.errors.exceptions.problem_response() and shorten_detail(): server.py (InvalidService, DuplicateService with serviceId=..., DuplicateService.hidden()) and verification.py (_not_verified()). All pass werkzeug exceptions (subclasses of BadRequest and Conflict) and no type, title, status or detail extension, which problem_response() rejects (ValueError); check that this still holds, and that every exception passed has an error status code and a description.
  • tests/test_exceptions.py keeps only the tests of the mapping; tests/test_app.py uses get_config().exceptions.max_detail_length instead of MAX_DETAIL_LENGTH.

Breaking changes and upgrade notes

For the next release (0.5.0), in docs/upgrading.md and deployment/README.md ("Upgrades", "To app version 0.5.0"):

  • Public URL: custom.endpoints.service is removed; set server.public_url to the absolute URL of the app as clients see it, including any path prefix of a proxy (formerly api_path), e.g., https://registry.example.org/ instead of url_prefix: https, external_host: registry.example.org, external_port: 443. The app refuses to start without it, and FOCA rejects URLs with query or fragment. In the chart, hostName keeps working; set publicUrl for anything else instead of config.custom.endpoints.service.
  • Admins required: custom.access_control.require_admin moves to security.access_control.require_admin (default true in the base config, as before); custom.access_control is rejected.
  • Gunicorn: the image loads foca.gunicorn_config; cloud_registry.gunicorn_config no longer exists. The settings are the same; custom commands that load the old module must load FOCA's.
  • Behaviour differences (no action needed, but noticeable):
    • No warning any more if no group claim is set at all (claim_groups unset without group_mapping); FOCA only warns of group_mapping without claim_groups (now an error).
    • FOCA's admin check also counts service clients mapped to admin and configured g rules (policies) granting it; the registry refuses service clients, so only the latter applies.
    • FOCA additionally warns of contactUrl and documentationUrl in reserved example domains, and does not check organization.name ("Example Organization").
    • Log messages of the checks and of rejected requests are FOCA's (other wording and loggers).

Acceptance criteria

  • FOCA 0.18.0 is released, and the app depends on foca>=0.18.0,<0.19 (pyproject.toml; the image requirements follow via scripts/image_requirements.py).
  • The code, config keys, tests and docs listed above are deleted or replaced; no copies of FOCA's features remain (grep for the names above finds nothing outside the release history).
  • Tests pass at 100% coverage, including the startup refusal without server.public_url, the Location header behind a path prefix, validation error details, and require_admin.
  • Chart tests cover hostName, publicUrl, require_admin under security.access_control, and the failures for config.custom.endpoints.service and config.custom.access_control; helm lint and the chart README check pass.
  • The docs describe server.public_url, publicUrl and require_admin, and link to FOCA's docs for the Gunicorn settings and startup checks; the strict docs build passes.
  • The upgrade notes cover the breaking changes and behaviour differences above.

Activity

  1. added
    priority: medium
    status: blocked
    type flag: breaking change
    type: maintenance
    workload: days
    on Oct 24, 2026
  2. added
    status: in progress
    and removed
    status: blocked
    on Oct 26, 2026
  3. removed
    status: in progress
    on Oct 27, 2026
  4. added this to the v0.6.0 milestone on Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: mediumtype flag: breaking changetype: maintenanceworkload: days

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions