Repository navigation
fix(plugins): read serviceId in discovery - #670
Conversation
Cloud Registry 1.0.0rc2 renames `service_id` to `serviceId` in `GET /verifications`, so discovery skipped every item and apps ended up without backends. Read `serviceId`, and keep accepting `service_id` for older registries. An invalid `serviceId` is not replaced by `service_id`. Also state in the docs that registries requiring login for reads can't be used, as they are read without a token. Closes #665 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Cloud Registry ignores surrounding whitespace in the group and artifact of service types, so services verified with such a spelling were dropped without a trace. Compare them the same way. Correct the comment on the verified version, as the registry lists the current version in both documents, and state in the docs that a verification covers neither version nor environment. Registries that require login count as unreachable, not as empty. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A new version that makes a service pending removes its verification, and `_is_api` now follows `_same` in ignoring surrounding whitespace too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideDiscovery now handles the Cloud Registry’s Sequence diagram for compatible registry verification discoverysequenceDiagram
participant Registry
participant RegistryCache
participant Discovery
participant BackendSelection
RegistryCache->>Registry: GET /verifications
Registry-->>RegistryCache: verification items
RegistryCache->>Discovery: _verifications(document)
Discovery->>Discovery: Read serviceId
alt serviceId is absent
Discovery->>Discovery: Read service_id
end
alt identifier is invalid
Discovery-->>RegistryCache: Skip and log item
else identifier is valid
Discovery-->>RegistryCache: verified service map
RegistryCache->>Registry: GET /services
Registry-->>RegistryCache: current service records
RegistryCache->>BackendSelection: select_services(verified, services)
BackendSelection->>BackendSelection: _is_api(api_type, api)
BackendSelection->>BackendSelection: _version(verified_type)
end
File-Level Changes
Possibly linked issues
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 #670 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 56 56
Lines 7230 7231 +1
=========================================
+ Hits 7230 7231 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="foca/plugins/backends/registry.py" line_range="144" />
<code_context>
+ else None
+ )
+ if not isinstance(service_id, str):
skipped += 1
continue
- verified[item["service_id"]] = (item.get("url"), item.get("type"))
</code_context>
<issue_to_address>
**Blank identifiers hide malformed verifications**
When a registry returns an empty `serviceId` (including alongside a valid legacy `service_id`), `_verifications` accepts an empty string as a service identifier and stores the verification under `""`; ordinary services then fail the membership check in `select_services`, which logs only at debug level, so the malformed registry entry can leave a backend undiscovered without a warning.
Treat empty identifiers as invalid and include them in the skipped-verifications warning.
</issue_to_address>Linked issues
#665 fix: read serviceId in backend discovery · 3 of 3 met
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | Read serviceId and keep accepting service_id for registries before rc2. |
✅ Met | _verifications reads serviceId first and uses service_id only when that key is absent. |
| 2 | Check the rest of discovery against the registry's current API. | ✅ Met | The change also matches API-type group and artifact values with surrounding whitespace ignored; discovery continues to use the existing GET /services fields. |
| 3 | Update the docs. | ✅ Met | The docs describe both verification identifier spellings and clarify verification coverage and the behavior of registries requiring login. |
Sourcery assessment
Needs a human reviewer. 1 finding to address first, and the identifier and API-type matching changes determine which registry-listed services become request candidates. If they admit the wrong service, requests could be sent to an unintended endpoint; reverting stops future routing but cannot undo requests already sent.
Blocking findings: foca/plugins/backends/registry.py:144
An empty identifier matches no service, so the item was dropped without the warning that malformed items get. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Closes #665
Cloud Registry 1.0.0rc2 renames
service_idtoserviceIdinGET /verifications(elixir-cloud-aai/cloud-registry#352). FOCA skipped every item, so an app such as proTES ended up with no backends. Discovery now readsserviceId, andservice_idfor older registries. An invalidserviceIddoesn't fall back toservice_id, so a malformed item can't stand in for a verification.I compared the rest of the discovery code with the OpenAPI spec and docs of Cloud Registry
dev(d3e4fd7) and the rename table of #353 and #355.GET /verificationsis the only renamed field that FOCA reads:GET /services(id,url,type,environment) is unchanged. Further changes:groupandartifactnow ignore surrounding whitespace as well as case, as the registry'sservice_key()does. Verified services with such a spelling were dropped without a log entry.No release notes change:
docs/releases/has no draft for 0.21.0, as the notes are added in the release-prep PR.Verification
Failing first: with the test fakes serving
serviceId, 18 tests oftests/plugins/test_plugin_backends.pyfailed, withSkipped 1 verifications without service identifier.Against real registries (own containers, own network, port 18665). Services were registered and verified through the API, with real tokens of a static test issuer; FOCA's
RegistryCachethen read them, with the unverified TES and the verified WES as decoys. Scripts:work/elixir-on-cloud/projects/foca-665-cr-check/(run.sh).Locally (Python 3.12):
pytest -m "not mongodb": 3231 passed, 2 skippedcoverageoffoca/plugins/backends: 100%ruff check,ruff format --check,mypy,ast-grep scan,mkdocs build --strict: passedNot run locally: tests marked
mongodb(they need the fixed port 12345, and other agents work in parallel), integration tests. CI runs them.CI: all checks passed on the pushed commit, including the MongoDB and integration tests that did not run locally (
CI passed).Declined review findings
GET /verificationssucceeds andGET /servicesthen fails: the last good list stays in use for up tomax_stale. It is confirmed, medium, and predates this PR. It isn't a mismatch with the registry's API, and changing what a partly failed read does to the cache is a design change, so it doesn't belong here. It is reported to the maintainer separately, with the unpaginatedGET /servicesagainst the 16 MiB response limit.test_verified_versionuses a payload that the registry can't produce: it still can between the two reads, and other registries may keep the verified type, so the check and its test stay.401:HttpErrorhandling is already tested, and the real401ran against the registry (table above).Open questions
None.
🤖 Generated with Claude Code
Summary by Sourcery
Update registry discovery to support current and legacy verification identifiers while aligning API type matching and registry behavior documentation with Cloud Registry.
Bug Fixes:
serviceIdverification field while retaining compatibility with olderservice_idresponses and rejecting malformed identifiers safely.Enhancements:
Documentation:
Tests: