Repository navigation
refactor!: use FOCA 0.18 features - #261
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Validation details come from FOCA (exceptions.validation_details), and problem() builds on FOCA's problem_response(), adding only the codes of conflicts. Tests use locked_enforcer() instead of the removed get_enforcer(). Refs #226 Co-Authored-By: Claude Opus 5.5 <[email protected]>
FOCA checks the group settings, requires admins (security.access_control.require_admin, moved from custom.access_control.require_admin), warns of placeholders in the service info and refuses service clients (require_no_service_clients()); the app's own copies are removed. The chart reads require_admin from its new place and rejects the old key. Refs #226 Co-Authored-By: Claude Opus 5.5 <[email protected]>
server.public_url replaces custom.endpoints.service; the app refuses to start without it, and FOCA's get_public_url() builds the Location header. The chart sets it from hostName or the new value publicUrl and rejects the old key. FOCA's get_custom_config() replaces the app's. Refs #226 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The image loads foca.gunicorn_config (same settings); cloud_registry.gunicorn_config is removed. Tests keep the checks of the image command and its health check port. Refs #226 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Refs #226 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Chart docs name the required image version, tests render publicUrl, docstrings and the dev overlay are clearer. Refs #226 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Refs #226 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Refs #226 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideThis PR upgrades the application to FOCA 0.18 and refactors duplicated configuration, error handling, startup validation, URL, and Gunicorn functionality to use FOCA's implementations, while migrating the Helm chart, documentation, and comprehensive test suite to the new 0.6.0 configuration contract. Sequence diagram for FOCA-backed application startupsequenceDiagram
participant Gunicorn
participant App as cloud_registry.app
participant FOCA
participant Config
Gunicorn->>App: create_app()
App->>FOCA: Foca.create_app()
FOCA->>Config: validate config and startup checks
FOCA-->>App: configured Connexion app
App->>FOCA: require_no_service_clients()
App->>Config: check server.public_url
App-->>Gunicorn: ready app or startup error
Sequence diagram for FOCA problem response handlingsequenceDiagram
participant Request
participant App as cloud_registry app
participant Problem as problem()
participant FOCA
Request->>App: HTTP request
App->>Problem: problem(exception)
Problem->>FOCA: problem_response(exception, extensions)
FOCA-->>Problem: problem details response
Problem-->>Request: JSON error response
Flow diagram for Helm public URL configurationflowchart TD
Values[Helm values]
Choice{publicUrl set?}
Explicit[server.public_url = publicUrl]
Host[server.public_url = https://hostName/]
Render[Rendered config]
Reject[Reject removed legacy keys]
Values --> Choice
Choice -->|yes| Explicit
Choice -->|no| Host
Explicit --> Render
Host --> Render
Values --> Reject
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
# Conflicts: # cloud_registry/app.py
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #261 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 20 19 -1
Lines 1975 1862 -113
==========================================
- Hits 1975 1862 -113 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
# Conflicts: # cloud_registry/app.py
Replace the temporary pins of the FOCA dev commit and its dev image by the release (PyPI and the 0.18.0-py3.13 image, by digest). Refs #226 Co-Authored-By: Claude Opus 5.5 <[email protected]>
uniqueg
marked this pull request as ready for review
October 27, 2026 02:47
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="deployment/templates/_helpers.tpl" line_range="151" />
<code_context>
-{{- end -}}
{{- if and (eq $requireAdmin "true") (not (has "admin" (values $mapping))) -}}
-{{- fail "config.security.access_control.group_mapping must map a group to the role admin (e.g., the admin group of the identity provider), or set config.custom.access_control.require_admin to false" -}}
+{{- fail "config.security.access_control.group_mapping must map a group to the role admin (e.g., the admin group of the identity provider), or set config.security.access_control.require_admin to false" -}}
{{- end -}}
{{- $_ := required "hostName must be set" .Values.hostName -}}
</code_context>
<issue_to_address>
**Operators cannot disable admin check**
When no group mapping grants `admin` while `require_admin` remains true, `$requireAdmin` and `$mapping` trigger the validation failure, whose message recommends the removed `config.custom.access_control.require_admin` key; the chart rejects that key, so operators following the message still cannot render the chart.
Update the failure message to name a supported way to disable the admin requirement.
</issue_to_address>
### Comment 2
<location path="tests/test_image_command.py" line_range="22" />
<code_context>
+ Without preloading the app, so that each worker creates it after
+ forking (MongoDB clients must not be shared across forks).
+ """
+ assert image_command()[:3] == [
+ "gunicorn",
+ "--config",
</code_context>
<issue_to_address>
**Extra Gunicorn overrides go unnoticed**
When the Docker command adds `--workers 2` after its config argument, `test_image_command` checks only the first three command elements, then checks the app URI and `preload_app`; adding `--workers 2` after the config argument still passes, although the image no longer uses FOCA's default worker settings.
Assert the complete expected image command, or assert the worker setting as well.
</issue_to_address>Sourcery assessment
Approval pending. 2 findings to address first.
Blocking findings: deployment/templates/_helpers.tpl:151, tests/test_image_command.py:22
Refs #226 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 27, 2026
uniqueg
added a commit
to elixir-cloud-aai/protes
that referenced
this pull request
Oct 29, 2026
Upgrade to FOCA 0.18 (foca>=0.18.0,<0.19, base image 0.18.0-py3.13) and replace proTES's copies of what FOCA now provides, as Cloud Registry did (elixir-cloud-aai/cloud-registry#261): - require_admin moves from custom.access_control to FOCA's security.access_control.require_admin; the old key stops the app and the chart with a hint - FOCA's startup checks replace the admin and group claim checks and the placeholder warning of the service info; proTES keeps its check of enforced access control and the warning without user groups - service clients are refused by require_no_service_clients() - the image runs Gunicorn with foca.gunicorn_config (same settings); pro_tes.gunicorn_config is gone - foca.get_custom_config(CustomConfig) replaces proTES's own - validation details are set explicitly (FOCA's new default) Tests apply rules changed in the database directly with mark_changed(), and the docs tell operators to restart proTES after such changes (FOCA 0.18 caches the enforcer). BREAKING CHANGE: custom.access_control.require_admin is now security.access_control.require_admin; the image loads foca.gunicorn_config; rejected requests get the validation reason as detail. Closes #331 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR upgrades the app to FOCA 0.18 and replaces the app's own copies of features that FOCA now provides.
FOCA is pinned to the release
foca>=0.18.0,<0.19(pyproject.toml), and the base image toelixircloud/foca:0.18.0-py3.13, pinned by digest. The merge conditions hold:Closes #226
What changes
exceptions.validation_details: true).problem()is now a thin wrapper around FOCA'sproblem_response(). It only adds the codes of conflicts (feat: tell 409 conflicts apart #247), so it stays rather than being deleted as the issue proposed.MAX_DETAIL_LENGTH,shorten_detail()(FOCA's is used),validation_problem(), and the handler and logger setup increate_app()are deleted.locked_enforcer()instead ofget_enforcer().ValueError),require_admin(moved fromcustom.access_control.require_admintosecurity.access_control.require_admin), the placeholder service info warning, andrequire_no_service_clients().check_admin_groups(),check_no_service_clients(),warn_placeholder_service_info()and thePLACEHOLDER_*constants.custom.access_controlstays, unlike in the issue text: it also holdsservice_typesandmax_unused_service_types, which were added after the issue was written. Onlyrequire_adminmoves.require_adminfrom its new place and rejects the old key.server.public_urlreplacescustom.endpoints.service;ServiceConfig,get_public_url()and_format_host()are deleted.create_app()refuses to start withoutserver.public_url.Locationheaders come from FOCA'sget_public_url().foca.get_custom_config(CustomConfig)replaces the app's own.hostName(https://<hostName>/) or the newpublicUrlvalue.publicUrlis in the values schema, with a pattern for http(s) URLs without query or fragment. The chart rejectsconfig.custom.endpoints.service.custom: {}, so thatconfig.custom: nullstill works.--config python:foca.gunicorn_config(same settings).cloud_registry/gunicorn_config.pyand its tests are deleted; tests of the image command and the health-check port remain.docs/upgrading.mdhas a new section "From 0.5.0", anddeployment/README.mda new section "To app version 0.6.0". Both cover the breaking changes and the behaviour differences listed in the issue, plus response-validation errors, which are now logged.require_admin.Verification
ruff check,ruff format,mypy cloud_registry tests: clean.mkdocs build --strict: clean.pre-commit run --all-files: passed.scripts/check_release_pins.pyreported both dev pins, as intended; with the release pins, it passes.publicUrlandhostName,publicUrlvalidation, docstrings, dev overlay order, and the upgrade notes on response-validation logs and the pre-0.4.0 step.Declined review findings
policiesrules and accepts issuer objects. The README now says to setrequire_admin: falsewhen only rules grant admin. Issuer objects belong to feat: support several token issuers #257 (several token issuers).problem_response()sends the mappedcode. A comment andtests/test_conflicts.pyguard this.config.server.public_urloverrides in the chart: FOCA validates it at startup, and the schema coverspublicUrl.foca-commonstays at 0.2.0 for now. Its schema$commentstill mentions FOCA 0.17 until a library release for 0.18 exists.Open questions
None.
🤖 Generated with Claude Code
Summary by Sourcery
Upgrade the application to FOCA 0.18 and migrate shared configuration, validation, startup checks, URL handling, and Gunicorn behavior to the library.
Enhancements:
Build:
Deployment:
Documentation:
Tests: