Skip to content

fix: address low-severity review findings - #121

Merged
uniqueg merged 43 commits into
devfrom
fix/review-low-findings
Oct 21, 2026
Merged

uniqueg merged 43 commits into
devfrom
fix/review-low-findings

Conversation

@uniqueg

@uniqueg uniqueg commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Summary

This PR fixes the low-severity findings of the pre-release review, bundled in #117. Items already fixed on dev were skipped: the maxLength limits and request body size limit (#119), HTTP(S)-only URLs (#118) and Gunicorn (#120).

App

  • Log escaping: request values in log messages are escaped with escape_log_value(). This is a copy of FOCA 0.15's helper and will switch to FOCA's in build: upgrade to FOCA 0.15 #104.
  • Races between PUT, DELETE and grants:
    • Non-admins never create a service with PUT. An unknown service, or one deleted after it was read, returns 404.
    • DELETE revokes roles before and after deleting the document.
    • Grants and restored owners check that the service still exists after storing the role. If it doesn't, the role is revoked and the request returns 404. On create, only the creator's own role is revoked, so a service re-created meanwhile keeps its owner.
  • GET /me: admin now asks the enforcer, so it includes admins added through the permissions API. The README documents that API.
  • Audit logs (INFO): owner on create, grants (with previous roles), revocations, deletions, and verifications removed by an update.
  • Validation:
    • createdAt/updatedAt must be RFC 3339 date-times (400 naming the field).
    • types is rejected as a service identifier and never generated.
    • 400 responses from request validation now pass the reason on. Details of all problem responses are shortened to 500 characters (in the middle, keeping the field name), and Connexion's own unbounded validation log messages are silenced; the app logs the shortened, escaped reason instead.

Helm

  • Rendering fails without a non-blank audience, unless verify_audience is false (also as the strings pydantic parses as false; null counts as true).
  • Pods don't mount service account tokens.
  • The deployment README describes TLS and rate limits at the Ingress, including an opt-in force-ssl-redirect example.

Build and CI

  • Compose publishes the app on 127.0.0.1 only.
  • The image ships the license text, and the base image is pinned by digest (Dependabot updates it).
  • The Compose CI job inserts a verified service and checks 9 API endpoints with curl and jq.
  • Dependabot also updates docs/api requirements.
  • Release workflow:
    • It requires a successful checks.yaml push run for the release commit.
    • It publishes docs/releases/<version>.md as release notes if that file exists, otherwise generated notes, and fails if that file contains TODO. Re-runs update the notes of an existing release.

Docs

Closes #117

Verification

  • coverage run --source=cloud_registry -m pytest: 707 passed, 100 % coverage. The race tests failed before their fixes.
  • ruff check, ruff format --check, mypy, semgrep (repo rules), ast-grep scan and ast-grep test: pass.
  • helm lint --strict (both CI variants) and helm template: pass.
  • actionlint and zizmor: no findings. The release workflow's shell logic was tested with a stubbed gh, and the CI-run query against the real repo.
  • Built the image and ran the Compose smoke test with the new API checks: pass.
  • Two rounds of adversarial and quality reviews; all confirmed findings fixed.
  • Not run locally: gitleaks (not installed) and the Read the Docs build.

CI: all checks pass (tests on Python 3.10 and 3.12, Helm chart, Compose with the new API checks, static analysis, codecov, Read the Docs).

Deferred

As decided for #117, these stay out of scope: per-user quotas (ingress rate limiting is documented instead), a full lock file for the requirements, promoting CI images in the release workflow, a NetworkPolicy, renaming chart values, and a pytest job against a real MongoDB.

Notes

Declined review findings

  • Sourcery: in-flight requests acting on a service deleted and re-created under the same identifier. This needs an admin and a window of milliseconds, the result is visible and fixable via the permissions API, and per-incarnation identifiers would change the stored schema.
  • Sourcery: a failed document delete leaves the service without roles. Revoking first is deliberate (the reverse order leaves roles on deleted identifiers); atomicity would need MongoDB transactions and a replica set. Admins can still manage the service.
  • Sourcery: seconds of 60 outside leap seconds. RFC 3339 leaves that check to applications; jsonschema doesn't do it either.
  • Sourcery: legacy timestamps and a legacy types identifier. 0.3.0 starts with an empty database.
  • Sourcery: VERSION missing in the Create release step. It is set in the job's env.

Open questions

None.

🤖 Generated with Claude Code

uniqueg and others added 30 commits October 21, 2026 06:00
Identifiers from request paths, user identifiers and messages naming
request values were logged as they are, so control characters could
forge or hide log lines. They are now logged with non-printable
characters escaped, by a local copy of FOCA 0.15's escape_log_value()
(in cloud_registry.utils), to be replaced by FOCA's with #104.

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
If a maintainer's `PUT /services/{serviceId}` overlapped with the
owner's `DELETE`, the replacement found no service on its next read and
inserted it again, and the maintainer became its owner. Roles left on
the identifier of a deleted service (e.g., if revoking them failed) also
let their holders register it again. This broke the rule that only
admins register services with chosen identifiers.

- `PUT` only inserts a service for admins (`is_admin()`, as the
  policies see it); for others, an unknown service, also one deleted
  after it was read, returns 404.
- `DELETE` revokes the roles on a service before it deletes it.

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A role granted on a service while it was being deleted stayed stored
after the deletion: the grant checked that the service exists before
the deletion, and stored the role after the deletion revoked the roles.
With a later registration of the identifier, the role would apply to
the new service.

- Grants (and restored owners) check again that the service exists
  after storing the role, and revoke it otherwise (404).
- `DELETE` revokes the roles on the service again after deleting it,
  for grants whose second check ran before the deletion.

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`GET /me` computed `admin` from group claims only, so users granted the
role `admin` via FOCA's permissions API
(`/admin/access-control/permissions`) were reported as `admin: false`,
although the policies treat them as admins. `admin` now comes from the
enforcer (`is_admin()`), like access decisions.

Document the permissions API in the README: admins only, it bypasses
the registry's checks (e.g., the last-owner check and the cleanup of
stored names), and how to grant and revoke the role `admin` with it.
Test that it is for admins only and that roles granted with it apply.

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Changes of roles and verifications were not logged with who made them,
so they couldn't be audited. The app now logs at level INFO:

- the owner role of a new service, granted to its creator;
- grants (with the previous roles) and revocations of roles, and the
  revocation of all roles of a service, with the user who made them;
- deletions of services;
- removals of verifications by updates of the URL or API type (and, as
  before, verifications and their removal by admins).

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`createdAt` and `updatedAt` are declared with `format: date-time`, which
jsonschema doesn't check without an optional package, so values such as
`yesterday` were stored and served on the GA4GH endpoints. Registrations
(`POST`, `PUT`) now check them with the RFC 3339 check of the service
info (`is_date_time()`, now public) and return 400 naming the field.

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A service registered with `PUT /services/types` could not be fetched,
as `GET /services/types` lists the service types. The identifier is
now rejected (400, like the dot segments), and skipped when generating
identifiers (`RESERVED_IDS`), in case the configured charset allows it.

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Requests rejected by Connexion's validation (e.g., of the request
schema or path parameters, invalid JSON, extra query parameters) got
the fixed detail "The request is malformed" (without the trailing
period of the other texts), as FOCA's error handler serves the details
mapped to the exception class. The app now registers its own handler
for `BadRequestProblem` and `ExtraParameterProblem`, which passes the
reason on as `detail` (e.g., "'name' is a required property"), and
falls back to the mapped details, now with the period.

No FOCA changes are needed: Flask picks the handler of the closest
exception class, so FOCA's handler still serves all other exceptions.

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Without `config.security.auth.audience`, the chart rendered, and the
app refused to start, which only showed as a crash-looping pod. Like
the admin group mapping, rendering now fails unless the audience lists
non-blank client IDs, or `verify_audience` is false (as FOCA checks on
startup). The chart tests set an audience by default and test the
check.

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Neither the app nor MongoDB calls the Kubernetes API, but both pods got
the token of the namespace's default service account, which a
compromised container could use. Both pods now set
`automountServiceAccountToken: false`. (A NetworkPolicy is left for
later.)

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The deployment README didn't say that the default Ingress serves plain
HTTP while the app advertises HTTPS URLs; only Helm's notes did. It now
explains the options (TLS in front of the cluster, or `https.enabled`
with cert-manager), and the optional `force-ssl-redirect` annotation
for TLS terminated in front of the cluster, with its prerequisite.

As the app doesn't limit registrations per user, it also recommends
rate limits at the ingress, with ingress-nginx annotations as an
example (per-user quotas are left for later). The README points to it.

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Docker Compose published the app on all interfaces of the host, while
its development config (`config.dev.yaml`) accepts tokens for any
audience and requires no admins. It now publishes it on 127.0.0.1 only;
an override file can publish it elsewhere, with a stricter config.

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The image didn't contain the Apache-2.0 license text, as
`.dockerignore` excluded `LICENSE`. It is now copied with the sources,
so that pip installs it with the package metadata
(`cloud_registry-<version>.dist-info/licenses/LICENSE`), as in the
wheel. CI checks that the wheel and the image contain it.

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The base image was referenced by a mutable tag, so rebuilds (e.g., the
release workflow's) could get another base image than the one tested.
It is now pinned by digest, with the tag kept for readability;
Dependabot's docker ecosystem updates both together. (A lock file of
the Python requirements is left for later.)

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The tests use mongomock, and the Compose smoke test only checked the
Swagger UI and the version, so no CI job called database-backed
endpoints against a real MongoDB. The smoke test now inserts a verified
service into the Compose MongoDB (writes need tokens of the trusted
issuer) and checks the read endpoints with curl and jq: the service
list (without internal fields), a service, the service types, the
verifications (with the stored date) and 404/401 responses.

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Dependabot skipped `docs/api/requirements.txt`, the pinned requirements
of the Read the Docs build. Add the pip ecosystem for `/docs/api`, with
its updates grouped.

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The release workflow checked the tag and that its commit is on `main`,
but not that CI passed for the commit, so a commit with failing tests
could be released. The `prepare` job now requires a successful run of
the CI workflow (`checks.yaml`) for a push of the commit, via the
workflow runs API with the workflow's token (`actions: read`). Runs for
pull requests don't count, as they test merge commits.

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Releases always got notes generated from the merged pull requests,
which don't explain breaking changes or upgrade steps. The release
workflow now passes `docs/releases/<version>.md` of the release commit
to `gh release create --notes-file` if it exists, and generates the
notes otherwise.

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The first release tagged from Git has many breaking changes since the
deployed version (chart 2, FOCA 0.12) and the legacy charts, but only
generated notes. `docs/releases/0.3.0.md`, which the release workflow
publishes, describes the upgrade (a fresh install with an empty
database, as the data of the deployed version can't be trusted; the
chart version going from 4.0.0 back to 0.3.0), the breaking changes of
the API, config, chart and image, and the new features. A marked TODO
line is left for the FOCA 0.15 upgrade and group roles (#104, #105).

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Test that a service deleted by another request between the existence
check and the deletion is not found, with its roles revoked.

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- deployment/README.md: the paragraph on upgrading to 0.3.0 said to
  run `helm upgrade` (with the removed `deploy/<appName>`), while
  releases of the legacy charts must be uninstalled. It now applies to
  releases installed with the current chart only, with the commands,
  and links the release notes. It no longer calls 0.3.0 "the first
  release after 0.2.0" (0.2.0 was never tagged).
- The warning without admin groups (and its docstring) said that
  nobody could set the service info, which comes from the config now;
  it names what admins do instead.
- pyproject.toml classified the project as alpha, the README as beta;
  the classifier is now "4 - Beta", as in the README.

Closes #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Validators quote rejected values in their messages, so a 400 response
for a large request body (up to 1 MiB) echoed nearly all of it, as did
its log message. Reasons longer than 500 characters are now shortened
in the middle (keeping, e.g., the field name at their end), in the
response and the log message.

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
test_delete_racing_grant never checked that its hook, which grants a
role while the service is deleted, ran at all, so it could pass
without testing the race. A helper now runs a callback once before
the first call of a collection method on a given collection, and
returns a flag that the race tests assert.

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Granting the owner role of a new service is not atomic with its
registration: the service may be deleted (with its roles) in between,
and the owner role (and name) would be left on the deleted service.
The existence is now checked again after granting it; if the service
is gone, its roles are revoked again, and the request returns 404, as
for grants via the permissions API.

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The chart refused to render without an audience in cases the app
accepts: with `verify_audience` given as a string that pydantic parses
as false (e.g., "false" or "False", as with `--set-string`), and
without trusted issuers (`issuers: []`), for which FOCA requires no
audience. The check now skips both.

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The description of `PUT /services/{serviceId}` (and the README) said
that non-admins get 404 for unknown services, but the policies return
403 first to anyone without a role on the identifier. They now say
that non-admins can only update services they have a role on, and
that services deleted during the request return 404.

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Curated release notes are published as written, so a TODO left in
them (as in the notes of 0.3.0 until #104 and #105 fill it in) would
end up in the GitHub release. The release workflow now fails before
publishing anything if the notes of the version contain TODO. The
README says so, in a re-wrapped paragraph (a line was too long).

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A re-run of the release workflow for an existing release uploaded the
chart and set `latest`, but kept the release's notes, e.g., of a
release created by hand. It now also sets the curated notes of the
version, if there are any, as a first run would.

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Four places deleted the display names stored for users on a service,
with the same query. A helper, `_forget_names()`, now does it, for
one user or all users of a service.

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The verification controllers escaped the current subject for log
messages themselves; they now use `permissions.current_user()`, as
the other controllers do.

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
uniqueg and others added 12 commits October 21, 2026 07:25
`is_date_time()` checks the timestamps of registered services as
well as those of the service info, so the service module imported it
from the service info module. It now lives in `cloud_registry.utils`;
the service info module still registers it as the check of the
`date-time` format.

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The paragraph on request body limits had an over-long line and also
covered request rates; rate limits now have their own paragraph.

The README said that changes via the permissions API are logged by
FOCA's request logging only. FOCA 0.14 logs the requests (method,
path, client address) and the identifiers of added, updated or
deleted policy rules, but neither who changed them nor how; the
README now says so.

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Connexion 2 logs the validator's message at ERROR before our error
handler, in full and unescaped; as validators quote rejected values,
a large invalid body produced a log record of nearly its size. The
app now sets Connexion's validation logger to CRITICAL, as the error
handler logs the reason shortened and escaped. This is done in
`create_app()`, as FOCA 0.14's log config forbids a `loggers` key
(and deployments replacing the log config keep it).

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
When a new service was deleted before its owner was stored, all roles
on its identifier were revoked. If another admin registered the
identifier again meanwhile, that service lost its owner. Only the
owner role this request granted (and the creator's stored name) is
now revoked, via the new `permissions.remove_owner()`.

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Only reasons of validation errors were shortened, but other problem
details quote request values, too (e.g., invalid URLs of services).
`_response()` now shortens every detail with the new
`shorten_detail()`, and log messages quoting descriptions of rejected
services and verifications use it as well, still escaped. Tests cover
the boundary (exactly `MAX_DETAIL_LENGTH` characters are kept, one
more are shortened) and joined messages of form data.

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The chart skipped the audience check for `issuers: []`, as FOCA
requires no audience then. But FOCA 0.14 refuses empty issuers while
access control is enabled, which the app needs, so the exception only
deferred the failure to startup. It is removed again.

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A `null` `verify_audience` disabled the chart's audience check (nil is
falsy in templates), while FOCA refuses it. It now counts as true. The
template comment names the pydantic version whose strings for false
the check mirrors.

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`is_date_time()` was only tested via the service info and the
registration endpoints. Parametrized tests in `tests/test_utils.py`
now cover valid date-times (with fractions, offsets and a leap
second), invalid dates, times and offsets, and non-strings, which
were checked in the service info tests before.

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Re-runs of the release workflow replace the notes of an existing
release with the curated ones, also discarding edits made on GitHub;
the README now says so.

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The test of a service deleted while it is created revoked the
creator's role in the simulated deletion already, so the revocation
by `remove_owner()` (and its log message) was never tested. The
deletion now finishes before the owner role is granted, as when its
revocations ran before.

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sourcery-ai

sourcery-ai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

This PR hardens the registry across application concurrency, validation, authorization, logging, deployment, packaging, CI, and release automation, with corresponding documentation and extensive regression coverage.

Sequence diagram for race-safe service deletion and role grants

sequenceDiagram
    participant Client
    participant Registry
    participant Permissions
    participant MongoDB

    Client->>Registry: deleteService(serviceId)
    Registry->>MongoDB: service_exists(serviceId)
    Registry->>Permissions: remove_permissions(serviceId)
    Permissions->>Permissions: remove_resource(service_path(serviceId))
    Registry->>MongoDB: delete_one(serviceId)
    Registry->>Permissions: remove_permissions(serviceId)
    Registry-->>Client: deleted service

    Client->>Permissions: putServicePermission(serviceId, userId)
    Permissions->>MongoDB: service_exists(serviceId)
    Permissions->>Permissions: add_resource_role(userId, role)
    Permissions->>MongoDB: service_exists(serviceId)
    alt service deleted meanwhile
        Permissions->>Permissions: remove_resource_role(userId, role)
        Permissions-->>Client: 404 NotFound
    else service still exists
        Permissions-->>Client: granted role
    end
Loading

Sequence diagram for admin-aware service registration and GET me

sequenceDiagram
    actor User
    participant API
    participant Enforcer
    participant MongoDB

    User->>API: putService(serviceId)
    API->>Enforcer: is_admin()
    alt admin
        API->>MongoDB: register_metadata(allow_create=true)
        API-->>User: 201 Created or 200 OK
    else non-admin
        API->>MongoDB: register_metadata(allow_create=false)
        alt service does not exist
            API-->>User: 404 NotFound
        else service exists
            API-->>User: 200 OK
        end
    end

    User->>API: getMe()
    API->>Enforcer: is_admin()
    Enforcer-->>API: group or permissions-API admin role
    API-->>User: user_id, admin, services
Loading

Flow diagram for bounded validation error handling

flowchart LR
    Request[Invalid API request] --> Connexion[Connexion validation]
    Connexion --> Handler[validation_problem]
    Handler --> Shorten[shorten_detail]
    Shorten --> Escape[escape_log_value]
    Escape --> Log[Bounded escaped INFO log]
    Shorten --> Response[400 problem response]
    Response --> Client[Client receives field-specific detail]
Loading

File-Level Changes

Change Details Files
Hardens service registration, permissions, deletion, and verification against concurrent mutations while adding auditability.
  • Restrict non-admin PUT requests to existing services and return 404 for deletion races.
  • Revoke roles before and after deletion, and roll back grants or creator ownership when the service disappears.
  • Log ownership, role changes, deletions, verification changes, and escaped request-derived values.
cloud_registry/ga4gh/registry/server.py
cloud_registry/ga4gh/registry/service.py
cloud_registry/ga4gh/registry/permissions.py
cloud_registry/ga4gh/registry/verification.py
tests/ga4gh/registry/test_server.py
tests/test_access_control.py
tests/test_verification.py
Improves API validation and error handling while exposing permissions-based administrators.
  • Validate service timestamps as RFC 3339 and reserve the types identifier.
  • Return validation reasons as bounded problem details and suppress Connexion's unbounded validation logs.
  • Determine GET /me admin status from the enforcer, including permissions API grants.
cloud_registry/app.py
cloud_registry/exceptions.py
cloud_registry/utils.py
cloud_registry/ga4gh/registry/service_info.py
cloud_registry/ga4gh/registry/permissions.py
cloud_registry/api/additions.openapi.yaml
tests/test_app.py
tests/test_exceptions.py
tests/test_utils.py
Hardens container and Helm deployment defaults and documents operational security requirements.
  • Require a non-blank audience during Helm rendering unless audience verification is explicitly disabled.
  • Disable service-account token mounts and bind Compose publishing to loopback.
  • Document TLS termination, ingress rate limiting, permissions API exposure, and upgrade behavior.
deployment/templates/cloud-registry-configmap.yaml
deployment/templates/cloud-registry-deploy.yaml
deployment/templates/mongo-deploy.yaml
deployment/values.yaml
docker-compose.yaml
deployment/README.md
README.md
tests/test_chart.py
tests/test_config.py
Strengthens packaging, CI smoke coverage, and release reproducibility.
  • Pin the Docker base image by digest and include the license in the built package and image.
  • Exercise database-backed endpoints and license presence in Compose CI.
  • Require successful push CI for the release commit and publish curated release notes with TODO and rerun handling.
Dockerfile
.github/workflows/checks.yaml
.github/workflows/release.yaml
.github/dependabot.yml
.dockerignore
pyproject.toml
Updates release and project documentation for the 0.3.0 deployment model.
  • Add 0.3.0 release notes, including upgrade and breaking-change guidance.
  • Correct stale upgrade text and update the package classifier to Beta.
docs/releases/0.3.0.md
README.md
deployment/README.md
pyproject.toml
Expands automated coverage for race conditions, validation, Helm configuration, logging, and integration behavior.
  • Add adversarial tests for concurrent service deletion and role grants.
  • Cover bounded validation details, escaped logs, RFC 3339 timestamps, audience rendering, token mounts, and Compose API checks.
tests/test_access_control.py
tests/test_app.py
tests/test_exceptions.py
tests/test_utils.py
tests/test_verification.py
tests/test_chart.py
tests/test_config.py
tests/helm.py

Assessment against linked issues

Issue Objective Addressed Explanation
#117 Fix access-control and data-integrity findings: prevent non-admin PUT/DELETE races from restoring deleted services, clean up roles during deletion and grants, make /me reflect admin roles, document the permissions API, and add audit logging. ✅
#117 Address API validation and logging findings, including validating registration timestamps, reserving the service ID types, preserving validation failure reasons, and escaping request-derived log values. ✅
#117 Resolve the applicable deployment, build, CI, release, and documentation findings, including release notes and upgrade guidance, audience render-time validation, chart hardening, local-only Compose publishing, license inclusion, API smoke checks, and Dependabot coverage. ✅

Possibly linked issues


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

@codecov

codecov Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (22e4acb) to head (20e25c9).

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #121   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           10        10           
  Lines          698       775   +77     
=========================================
+ Hits           698       775   +77     

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

@uniqueg
uniqueg marked this pull request as ready for review October 21, 2026 06:07

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

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="cloud_registry/ga4gh/registry/permissions.py" line_range="324" />
<code_context>
+        ValueError: The user identifier can't be stored in policy rules.
+    """
+    add_resource_role(subject=userId, role=role, resource=resource)
+    if not service_exists(serviceId):
+        remove_resource_role(subject=userId, role=role, resource=resource)
+        _forget_names(serviceId, userId)
</code_context>
<issue_to_address>
**Operations affect replacement services**

When a service is deleted and recreated with the same ID while an authorized request or permission cleanup remains in flight, iD-only checks in `_grant()`, `_replace()` and `_register_service()` treat the replacement as the original, so stale requests grant roles, overwrite it or return success. `remove_permissions()` and `remove_owner()` can also erase its new roles and stored names, so callers see unauthorized changes or lose access.

Give each service incarnation a distinct identifier and use it in existence and compare-and-swap checks and permission cleanup, so in-flight operations cannot act on a replacement.

Also at `cloud_registry/ga4gh/registry/server.py:134-135`, `cloud_registry/ga4gh/registry/server.py:247-251`, `cloud_registry/ga4gh/registry/service.py:631-633`, `cloud_registry/ga4gh/registry/permissions.py:325-326`.
</issue_to_address>

### Comment 2
<location path="cloud_registry/ga4gh/registry/server.py" line_range="129" />
<code_context>
     db_collection_service = get_collection("services")
+    if not service_exists(serviceId):
+        raise NotFound
+    remove_permissions(serviceId)
     res = db_collection_service.delete_one({"id": serviceId})
     if not res.deleted_count:
</code_context>
<issue_to_address>
**Failed deletion revokes service access**

When permission cleanup succeeds but deleting the service document fails, `deleteService()` has already removed roles and stored names when `delete_one()` fails, leaving the still-registered service without its owners or maintainers; only an admin can recover access.

Make permission revocation and document deletion atomic, or restore the removed permissions when deletion fails.
</issue_to_address>

### Comment 3
<location path="cloud_registry/utils.py" line_range="149" />
<code_context>
-    # Seconds may be 60 (leap seconds)
-    return (
-        parts["hour"] < 24
-        and parts["minute"] < 60
-        and parts["second"] <= 60
-        and parts["offset_hour"] < 24
</code_context>
<issue_to_address>
**Invalid leap seconds are accepted**

When a registration supplies seconds `60` at a date and time that is not a valid leap-second boundary, `is_date_time()` accepts the value and `check_date_times()` stores it, so registration succeeds with a timestamp that violates RFC 3339.

Validate seconds `60` only at an actual RFC 3339 leap-second boundary.

Also at `cloud_registry/utils.py:151`.
</issue_to_address>

### Comment 4
<location path=".github/workflows/release.yaml" line_range="242" />
<code_context>
         run: |
+          # Curated notes of the release commit if there are any, otherwise
+          # notes generated from the merged pull requests
+          notes_file="docs/releases/${VERSION}.md"
           # On reruns, complete an existing release instead of failing
           if gh release view "${TAG}" > /dev/null 2>&1; then
</code_context>
<issue_to_address>
**Curated release notes are skipped**

When a release has a `docs/releases/<version>.md` file, the `Create release` step never defines `VERSION` in its `env`, so `notes_file` resolves to `docs/releases/.md`. The workflow therefore generates notes instead of publishing curated notes, and reruns do not update existing release notes from the curated file.

Pass the release version into the `Create release` step’s environment, for example from `needs.prepare.outputs.version`.
</issue_to_address>

### Comment 5
<location path="cloud_registry/ga4gh/registry/service.py" line_range="556" />
<code_context>
         check_strings(self.data)
         key = service_key(self.data)
         check_links(self.data)
+        check_date_times(self.data)
         self._check_duplicate(key=key)

</code_context>
<issue_to_address>
**Legacy timestamps remain invalid**

When the database contains a service with a non-RFC-3339 `createdAt` or `updatedAt` from before this validation, the registration-only check leaves previously stored invalid timestamps unchanged, and the service-list and service-by-ID readers return those records as-is. Clients still receive values that violate the API's date-time format after upgrade; migrate or validate existing records too.

Migrate invalid stored timestamps or detect them during startup and require correction before serving those records.
</issue_to_address>

### Comment 6
<location path="cloud_registry/ga4gh/registry/service.py" line_range="63" />
<code_context>
+# Identifiers that can't be used for services: dot segments, which clients
+# resolve in URLs, and `types`, as `/services/types` lists the service types
+# (cf. the pattern of `serviceId` of `PUT` in `additions.openapi.yaml`)
+RESERVED_IDS = frozenset({".", "..", "types"})
 PERCENT_ENCODED = re.compile(r"%([0-9A-Fa-f]{2})")
 # Percent signs not starting a percent-encoding
</code_context>
<issue_to_address>
**Legacy `types` service remains inaccessible**

When the database already contains a service whose identifier is `types`, the new reservation prevents future registrations but does not migrate an existing `id: types` document; `GET /services/types` continues to resolve to the types-list endpoint, leaving that stored service inaccessible by its ID after upgrade. Migrate, rename or explicitly reject startup with such a row.

Add a migration or startup validation for existing reserved identifiers before relying on the new registration checks.

Also at `cloud_registry/api/additions.openapi.yaml:125`.
</issue_to_address>

### Comment 7
<location path="cloud_registry/exceptions.py" line_range="108" />
<code_context>
+    if len(detail) <= MAX_DETAIL_LENGTH:
+        return detail
+    head = MAX_DETAIL_LENGTH // 2
+    return f"{detail[:head]}…{detail[head - MAX_DETAIL_LENGTH :]}"
+
+
</code_context>
<issue_to_address>
**Problem details exceed limit**

When a problem detail exceeds 500 characters, `shorten_detail()` keeps 250 characters from each end and adds an ellipsis, so details longer than the limit are 501 characters despite `MAX_DETAIL_LENGTH` being 500. Callers receive problem details one character over the documented cap.

Reserve one character of the 500-character budget for the ellipsis when choosing the head and tail slices.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 6 findings to address first, and the change alters who can create services and who is treated as an admin, and adds direct management of stored permission rules. If those checks are wrong, users could gain or lose access, or service records could be deleted; reverting the code would not restore changed policies or deleted records.

Blocking findings: cloud_registry/ga4gh/registry/permissions.py:324, cloud_registry/ga4gh/registry/server.py:129, cloud_registry/utils.py:149, .github/workflows/release.yaml:242, cloud_registry/ga4gh/registry/service.py:556, and 1 more


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

Comment thread cloud_registry/ga4gh/registry/server.py Resolved
Comment thread cloud_registry/utils.py Resolved
Comment thread .github/workflows/release.yaml Resolved
Comment thread cloud_registry/exceptions.py Resolved
Shortened problem details were one character longer than
MAX_DETAIL_LENGTH, as the ellipsis came on top of the kept characters.
Keep one character less of the end, so that they have exactly
MAX_DETAIL_LENGTH characters. Found by Sourcery.

Refs #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

chore: low findings of the v0.3.0 review

1 participant