Skip to content

build: bump FOCA to 0.22.0 - #100

Merged
uniqueg merged 4 commits into
devfrom
build/foca-0.22
Nov 9, 2026
Merged

uniqueg merged 4 commits into
devfrom
build/foca-0.22

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Summary

Bumps FOCA to 0.22.0, following its migration guide, as in Pubgrade-Sidecar (elixir-cloud-aai/Pubgrade-Sidecar#51).

  • Base image elixircloud/foca:0.22.0-py3.13 (pinned by digest), foca>=0.22.0,<0.23 in pyproject.toml, uv.lock updated (only foca changes).
  • .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.
  • Exception map and the endpoints' Unauthorized: the classes of foca.errors instead of Werkzeug's/Connexion's, which FOCA 0.22 logs as deprecated at startup. FOCA maps a foca.errors class and the Werkzeug class it derives from alike, so errors that Flask raises keep their problem details.
  • notify_subscriptions_threaded(): collection("builds") (FOCA's get_collection()) instead of app.config.foca, which FOCA 0.22 deprecates; the integration fixture test reads the config via get_config().
  • Requests that don't match the API's schemas now get type, code and errors (the invalid fields, without their values), and detail names the fields (FOCA 0.22 default). The specification's Error schema (new FieldError), docs/api.md and docs/deployment.md document it; FOCA 0.21 → 0.22 in docs/deployment.md and docs/development.md.

Closes #99

Verification

  • uv lock --check: passed
  • pre-commit run --all-files and --hook-stage manual gitleaks-all: passed (ruff, mypy, actionlint, gitleaks)
  • pytest --cov: 665 passed, 100% coverage (with mongomock)
  • mkdocs build --strict (with the external/pubgrade-sidecar submodule): passed
  • docker build: passed; Trivy on the built image: no fixable findings, zlib1g no longer reported
  • Not run locally: the smoke test and chart tests (need a running Pubgrade with MongoDB, and helm); CI runs them.
  • CI (run 42617792435, head 0b6c5d9): all jobs passed, incl. Smoke test, Upgrade test, Scan image (both images); image pushes skipped on PRs

Lane

Full lane (dependency bump with code changes): adversarial and quality reviews; round 1 lows fixed (docs list, Forbidden case, endpoint tests expect foca.errors classes, oneOf in FieldError); round 2 (quality) had no findings.

Declined review findings

  • Bump the API version (2.1.0) for the new error members: not done, as in Pubgrade-Sidecar; the members are additive, and no 2.x is released yet, so the upgrade notes for API 2.0.0 cover them.
  • Rewrite the first commit ("(WIP)" subject): the branch is pushed, so no rebase; the squash merge takes the PR title.
  • Comment on the empty .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)

  • Many unit tests set flask_config.foca = Config(...) on plain Flask apps and use Flask's test client; pubgrade/modules/server.py and subscriptions.py use flask.request and current_app. They don't warn on 0.22 but break with FOCA's ASGI release: move to foca.testing, foca.context.current_request() and get_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 adds errors for them, now tested. Both threads resolved.

🤖 Generated with Claude Code

uniqueg and others added 2 commits November 9, 2026 10:40
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]>
@sourcery-ai

sourcery-ai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

API

Extend the public error schema with FOCA 0.22’s structured invalid-field details, including exactly one body pointer or parameter location.

  • pubgrade/api/pubgrade.yaml L1378-1429

Document the new schema-invalid request response and its treatment of invalid fields, and update the deployment upgrade notes for FOCA 0.22.

  • docs/api.md L69-104
  • docs/deployment.md L206-208, L228-229, L292

Uses of the API

Use FOCA’s exception classes in endpoint code and replace deprecated direct access to the builds collection with the collection helper.

  • pubgrade/errors/exceptions.py L3-13, L130-132, L139
  • pubgrade/modules/endpoints/builds.py L12, L19 (removed lines)
  • pubgrade/modules/endpoints/repositories.py L9, L12 (removed lines)
  • pubgrade/modules/endpoints/subscriptions.py L9, L12 (removed lines), L446
  • pubgrade/modules/endpoints/users.py L6, L8 (removed lines)

Configuration

Pin FOCA 0.22.0 in the base image and Python dependency, and remove vulnerability exceptions no longer needed with the updated image.

  • .trivyignore.yaml L8
  • Dockerfile L13
  • pyproject.toml L34

Documentation

Update the development guide to identify FOCA 0.22 as the application foundation.

  • docs/development.md L44

Tests

Verify structured schema-validation errors, malformed bodies, unknown parameters and fields, and FOCA configuration access in integration tests.

  • tests/integration/test_api.py L720-768
  • tests/integration/test_fixtures.py L4, L14-16

Update endpoint tests to expect FOCA exception classes and test that Werkzeug-raised exceptions still receive the mapped problem details.

  • tests/pubgrade/endpoints/test_builds.py L15, L22 (removed lines)
  • tests/pubgrade/endpoints/test_repositories.py L11, L16 (removed lines)
  • tests/pubgrade/endpoints/test_subscriptions.py L10, L15 (removed lines)
  • tests/pubgrade/endpoints/test_users.py L8, L13 (removed lines)
  • tests/test_exceptions.py L10-16, L81-117

Lock files and vendored code

Record the dependency resolution for the FOCA version bump.

  • uv.lock L571, L594-596, L1237

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

@read-the-docs-community

read-the-docs-community Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 Pubgrade | 🛠️ Build #35753628 | 📁 Comparing 0b6c5d9 against latest (b8b0756)

  🔍 Preview build  

3 files changed
± api/index.html
± deployment/index.html
± development/index.html

@codecov

codecov Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (b8b0756) to head (0b6c5d9).

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.
📢 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.

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]>
@uniqueg
uniqueg marked this pull request as ready for review November 9, 2026 12:25
@uniqueg
uniqueg requested a review from akash2237778 as a code owner November 9, 2026 12:25

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


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

Comment thread docs/api.md Resolved
Comment thread pubgrade/errors/exceptions.py Resolved
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]>
@uniqueg
uniqueg merged commit 5ae9d84 into dev Nov 9, 2026
46 checks passed
@uniqueg
uniqueg deleted the build/foca-0.22 branch November 9, 2026 12:40
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.

build: bump FOCA to 0.22.0

1 participant