Repository navigation
build: move to FOCA 0.21 - #369
Conversation
Update the pin, lock and base image. Adapt tests and docs to FOCA's stricter request checks. Drop the uri format of serviceInfoUrl, so that rejected addresses, which can hold secrets, are neither logged nor returned. Closes #368 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideMoves the registry to FOCA 0.21.0, updating pinned runtime artifacts and adapting API behavior, tests, and documentation for stricter request and response validation. The change also prevents service-info validation errors from exposing sensitive addresses and warns operators about invalid stored service data that could make reads fail. Sequence diagram for startup detection of invalid stored service datasequenceDiagram
participant App
participant Registry
participant Database
participant Logger
App->>Registry: warn_invalid_formats()
Registry->>Database: find invalid URI and date-time fields
Database-->>Registry: stored services
alt invalid formats found
Registry->>Logger: logger.error(service IDs)
end
Sequence diagram for service-info address validation without leaking rejected valuessequenceDiagram
participant Importer
participant Validator
participant Fetcher
Importer->>Validator: service_url(address, schemes)
alt address exceeds MAX_ADDRESS_LENGTH
Validator-->>Importer: InvalidService
else invalid scheme, query, fragment, or path
Validator-->>Importer: InvalidService
else valid service-info address
Validator-->>Importer: service URL
Importer->>Fetcher: fetch service URL
end
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
FOCA checks formats of responses, so one such service makes GET /services return 500. Name them on startup. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Check the length of serviceInfoUrl in the app, so that FOCA doesn't quote rejected addresses. Cover the handlers behind FOCA's checks. 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="cloud_registry/ga4gh/registry/service.py" line_range="767" />
<code_context>
+ UPDATED: True,
+ },
+ ):
+ organization = service.get("organization") or {}
+ uris = [
+ service.get("url"),
</code_context>
<issue_to_address>
**Worker fails to start**
When a stored service has a truthy non-object `organization` value, `warn_invalid_formats()` calls `.get()` on `organization`, raising `AttributeError` during `create_app()` and preventing the Gunicorn worker from starting.
Check that `organization` is an object before reading its URL, and mark the service invalid otherwise.
</issue_to_address>
### Comment 2
<location path="cloud_registry/ga4gh/registry/service.py" line_range="776" />
<code_context>
+ ]
+ dates = [service.get(field) for field in DATE_TIME_FIELDS]
+ if not all(is_uri(value) for value in uris if value is not None) or not all(
+ is_date_time(value) for value in dates if value is not None
+ ):
+ ids.append(f"'{service.get('id')}'")
</code_context>
<issue_to_address>
**Invalid services escape startup warning**
When a stored service has a non-string timestamp or an explicit null URI or timestamp field, `warn_invalid_formats()` skips explicit nulls and `is_date_time()` accepts non-strings, so invalid services are omitted from the startup warning; FOCA then rejects their responses and service reads return `500`.
Validate stored URIs and timestamps against the response schema, including explicit nulls and timestamp types, before deciding whether to name the service.
</issue_to_address>Linked issues
#368 Move to FOCA 0.21 · 3 of 3 met
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | Pin FOCA 0.21, update the lockfile, and use the 0.21.0 base image by digest. | ✅ Met | The dependency pin, lockfile, and Docker base image are updated. |
| 2 | Adapt tests for the stricter checks: extra query parameters, invalid date-time and URI values, and unpaired surrogates. | ✅ Met | Tests cover the changed validation cases and FOCA's error details. |
| 3 | Document the stricter 400 responses in the API documentation and upgrade notes. | ✅ Met | Both docs/api.md and docs/upgrading.md describe the stricter responses. |
Sourcery assessment
Needs a human reviewer. 2 findings to address first, and FOCA now includes some invalid URI values in 400 responses and logs, so a secret accidentally submitted in one of those fields could persist in logs even after the change is reverted. The service-info URL field is excluded from this validation, but other URI fields still have this exposure.
Blocking findings: cloud_registry/ga4gh/registry/service.py:767, cloud_registry/ga4gh/registry/service.py:776
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #369 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 27 27
Lines 3238 3259 +21
=========================================
+ Hits 3238 3259 +21 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
A non-object organization no longer stops the app from starting, and null or non-string values are reported. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The mongomock entry takes about 19 minutes on dev and hit the 20-minute limit at 93% on PR 369. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Closes #368
Summary
foca>=0.21.0,<0.22, updateuv.lock, and use the FOCA 0.21.0 base image by digest (the same as proTES PR 434).date-timeandurivalues, unpaired surrogates.400responses indocs/api.mdanddocs/upgrading.md.format: uriandmaxLengthfromserviceInfoUrl: otherwise FOCA returns and logs rejected addresses, which can hold secrets. The app's own checks handle them, with the same 2061 limit, and the test now covers all loggers and the response.Invalid stored values
FOCA also checks the formats of responses, so one stored service with an invalid
date-timeorurivalue makesGET /servicesreturn500for everyone. FOCA registers the format checks globally on the checker Connexion uses, so they can't be turned off per response; the only switch in the app isvalidate_responsesfor the whole API, which I left on.refuse_old_format()already stops the app from starting on rc1 data, unless that data is migrated around it. As a safeguard,warn_invalid_formats()logs an error on startup naming such services, anddocs/upgrading.mdsays what to do. It finds them but doesn't prevent the500, and the list stays down until they are corrected or deleted.Verification
Local, Python 3.13, chart dependencies built with
helm dependency build deployment, checksum OK:coverage run -m pytest: 2327 passed, 11 skipped, 100% coverage, including the chart tests.ruff check,ruff format,mypy .: passed.mkdocs build --strictpassed before the last two commits; CI covers it.CI: see the checks of this PR.
Unrelated fixes
ci: give the test jobs 30 minutes: the mongomock entry takes about 19 minutes ondevand was cancelled at 93% by the 20-minute limit on this PR.Declined review findings
POST /servicesstill logs and returns a rejectedurlwith whitespace, which may hold credentials: the field'sformat: uricomes from the GA4GH specification, so this is left in place and documented. The general fix belongs in FOCA.POST /servicesfields can leak the same way through schema messages, e.g.maxLength: same reason._check_pending_update, for example) are kept as a second line, and because other paths use them.Open questions
None.
🤖 Generated with Claude Code
Summary by Sourcery
Upgrade the registry to FOCA 0.21 and adapt validation, safeguards, documentation, and CI to its stricter API and response checks.
Bug Fixes:
Enhancements:
Build:
CI:
Documentation:
Tests: