Repository navigation
build: bump FOCA to 0.22.0 - #100
Conversation
Base image, foca pin and lock to 0.22.0; drop the zlib1g Trivy entries; exception map and raises from foca.errors; get_collection instead of app.config.foca; invalid-field tests; spec Error schema and docs. Not yet reviewed; the docs build needs the submodule. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Split the paragraph on 400s with invalid fields into a short list, require exactly one location (pointer or parameter) in FieldError, and test that Werkzeug's Forbidden gets the mapped details too. The previous commit replaced app.config.foca with collection(), which calls foca's get_collection(). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideAPIExtend the public error schema with FOCA 0.22’s structured invalid-field details, including exactly one body pointer or parameter location.
Document the new schema-invalid request response and its treatment of invalid fields, and update the deployment upgrade notes for FOCA 0.22.
Uses of the APIUse FOCA’s exception classes in endpoint code and replace deprecated direct access to the builds collection with the collection helper.
ConfigurationPin FOCA 0.22.0 in the base image and Python dependency, and remove vulnerability exceptions no longer needed with the updated image.
DocumentationUpdate the development guide to identify FOCA 0.22 as the application foundation.
TestsVerify structured schema-validation errors, malformed bodies, unknown parameters and fields, and FOCA configuration access in integration tests.
Update endpoint tests to expect FOCA exception classes and test that Werkzeug-raised exceptions still receive the mapped problem details.
Lock files and vendored codeRecord the dependency resolution for the FOCA version bump.
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 #100 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 17 17
Lines 1518 1517 -1
=========================================
- Hits 1518 1517 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The endpoints raise the classes of foca.errors; the tests expected Werkzeug's, of which those are subclasses, so a return to Werkzeug's classes went unnoticed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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="docs/api.md" line_range="91" />
<code_context>
+ body or `parameter`) and a stable `code` (see FOCA's
+ [invalid request](https://foca.readthedocs.io/en/latest/problems/invalid-request/)).
+- Values of the request are left out, but names of unknown parameters and
+ body fields are echoed.
+- `detail` names the invalid fields.
+- Other invalid requests get no `errors`: bodies that aren't JSON or are
</code_context>
<issue_to_address>
**Unknown body fields are not reported**
When a request body contains an unknown field but otherwise satisfies the schema, clients expecting an unknown body field to appear in `errors` instead get a successful response when the remaining body is valid; Pubgrade accepts the extra field and omits it from storage. The new documentation therefore promises a validation error that the API does not return.
Clarify that unknown body fields are accepted and discarded, or change validation to reject them and include them in `errors`.
</issue_to_address>
### Comment 2
<location path="pubgrade/errors/exceptions.py" line_range="139" />
<code_context>
"detail": "An unexpected error occurred.",
},
- BadRequestProblem: {
+ RequestValidationProblem: {
"title": "Bad Request",
"status": 400,
</code_context>
<issue_to_address>
**Unknown query errors omit field details**
When a request includes an undeclared query parameter, strict validation sends the request through `ExtraParameterProblem`, whose exception mapping supplies only `title`, `status`, and `detail`; callers therefore receive no invalid parameter name or code.
Add the promised `type`, `code`, and `errors` fields to the `ExtraParameterProblem` mapping for unknown query parameters.
Also at `docs/api.md:91`, `docs/deployment.md:228-229`.
</issue_to_address>Linked issues
#99 build: bump FOCA to 0.22.0 · 5 of 5 met
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | Bump foca in pyproject.toml and uv.lock, and the base image tag and digest in the Dockerfile. | ✅ Met | The dependency constraint and lockfile use 0.22.0, and the Dockerfile pins the 0.22.0 image by digest. |
| 2 | Remove the zlib1g vulnerability entries from .trivyignore.yaml. | ✅ Met | The two CVE entries are removed and the vulnerability list is empty. |
| 3 | Use classes of foca.errors instead of Werkzeug's in the exception map and raised errors. | ✅ Met | The exception map and endpoint Unauthorized imports use foca.errors classes. |
| 4 | Replace deprecated app.config.foca access with get_config() or get_collection(). | ✅ Met | Production settings and collection access use FOCA's helpers; the changed integration fixture reads configuration with get_config(). |
| 5 | Update tests and docs for validation-error details that name invalid fields listed in errors. | ✅ Met | Integration tests check the field-specific detail and errors, and the API specification and documentation describe them. |
Sourcery assessment
Needs a human reviewer. 1 finding to address first, the security scan did not finish, and the FOCA image and dependency upgrade changes runtime behavior, and the notification endpoint now writes results through a different collection accessor. If that accessor targets the wrong collection or fails, notification records may be missing or misplaced; the damage is bounded and can be repaired, and reverting restores the prior code.
Blocking findings: pubgrade/errors/exceptions.py:139
Unknown query parameters are always invalid fields, unknown body fields only where the schema forbids them (e.g., POST /repositories); others are accepted and dropped. Test both. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Bumps FOCA to 0.22.0, following its migration guide, as in Pubgrade-Sidecar (elixir-cloud-aai/Pubgrade-Sidecar#51).
elixircloud/foca:0.22.0-py3.13(pinned by digest),foca>=0.22.0,<0.23inpyproject.toml,uv.lockupdated (onlyfocachanges)..trivyignore.yaml: the zlib1g entries of ci: accept zlib1g findings until FOCA 0.22.0 #92 (CVE-2026-76844, CVE-2026-85091) are dropped; the 0.22.0 base image has the fix.Unauthorized: the classes offoca.errorsinstead of Werkzeug's/Connexion's, which FOCA 0.22 logs as deprecated at startup. FOCA maps afoca.errorsclass and the Werkzeug class it derives from alike, so errors that Flask raises keep their problem details.notify_subscriptions_threaded():collection("builds")(FOCA'sget_collection()) instead ofapp.config.foca, which FOCA 0.22 deprecates; the integration fixture test reads the config viaget_config().type,codeanderrors(the invalid fields, without their values), anddetailnames the fields (FOCA 0.22 default). The specification'sErrorschema (newFieldError),docs/api.mdanddocs/deployment.mddocument it; FOCA 0.21 → 0.22 indocs/deployment.mdanddocs/development.md.Closes #99
Verification
uv lock --check: passedpre-commit run --all-filesand--hook-stage manual gitleaks-all: passed (ruff, mypy, actionlint, gitleaks)pytest --cov: 665 passed, 100% coverage (with mongomock)mkdocs build --strict(with theexternal/pubgrade-sidecarsubmodule): passeddocker build: passed; Trivy on the built image: no fixable findings, zlib1g no longer reportedLane
Full lane (dependency bump with code changes): adversarial and quality reviews; round 1 lows fixed (docs list, Forbidden case, endpoint tests expect
foca.errorsclasses,oneOfinFieldError); round 2 (quality) had no findings.Declined review findings
.trivyignore.yaml:vulnerabilities: []is how the file looked before ci: accept zlib1g findings until FOCA 0.22.0 #92.Follow-ups (ASGI release, not needed for 0.22)
flask_config.foca = Config(...)on plain Flask apps and use Flask's test client;pubgrade/modules/server.pyandsubscriptions.pyuseflask.requestandcurrent_app. They don't warn on 0.22 but break with FOCA's ASGI release: move tofoca.testing,foca.context.current_request()andget_config().Open questions
None.
Automated reviews
Sourcery: a low (unknown body fields accepted on some calls) clarified in the docs with a test (0b6c5d9); a medium (unknown query parameters without
errors) answered: FOCA 0.22 addserrorsfor them, now tested. Both threads resolved.🤖 Generated with Claude Code