Repository navigation
feat!: return 201 Created for new services - #110
Merged
Merged
Conversation
`POST /services` returns `201 Created` with a `Location` header
pointing to the new service, and `PUT /services/{serviceId}` returns
`201` with `Location` when it creates a service and `200` when it
replaces one. The body is still the service ID.
Public URLs are built by one helper, `get_public_url()`, from
`custom.endpoints.service`, the proxy prefix `api_path`, the script
root and the percent-encoded request path.
Closes #78
BREAKING CHANGE: `POST /services`, and `PUT /services/{serviceId}`
for new services, return `201` instead of `200`.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reject the service IDs `.` and `..` (also percent-encoded), whose `Location` clients would resolve elsewhere, bracket IPv6 hosts in public URLs, and build the `Location` path from the collection path passed by the controllers. Set public URLs for Docker Compose (`http://localhost:8080`) and document them in a "Public URLs" section. Share a `ServiceId` schema in the spec and tidy up the tests. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Bracket only hosts that are IPv6 addresses, with percent-encoded zone IDs (RFC 6874), so that misconfigured hosts with ports aren't bracketed. Derive the collection path of PUT requests by removing the service ID, add a type alias for registration responses, explain the ID pattern, and document that services registered with the IDs `.` or `..` must be registered again to be updated. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideService registration now returns RESTful creation responses ( Sequence diagram for service registration responsessequenceDiagram
participant Client
participant API
participant Registry
participant Config
Client->>API: POST /services or PUT /services/{serviceId}
API->>Registry: _register_service(collection_path, service_id)
alt New service
Registry->>Config: get_public_url(path)
Config-->>Registry: Location URL
Registry-->>API: serviceId, 201, Location
API-->>Client: 201 Created + identifier + Location
else Existing service replacement
Registry-->>API: serviceId
API-->>Client: 200 OK + identifier
end
Flow diagram for service identifier validationflowchart TD
Request["PUT /services/{serviceId}"] --> Validate{serviceId is . or ..?}
Validate -->|Yes| BadRequest["400 Bad Request"]
Validate -->|No| Register["Register or replace service"]
Register --> Response["201 for new service; 200 for replacement"]
File-Level Changes
Assessment against linked issues
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 #110 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 8 8
Lines 462 492 +30
=========================================
+ Hits 462 492 +30 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
uniqueg
marked this pull request as ready for review
October 20, 2026 19:18
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/utils.py" line_range="56" />
<code_context>
+ conf = get_custom_config().endpoints.service
+ host = _format_host(conf.external_host)
+ # `api_path` is configured as it appears in URLs, so it isn't encoded
+ parts = (conf.api_path, quote(request.script_root + path))
+ url_path = "/".join(filter(None, (part.strip("/") for part in parts)))
+ return f"{conf.url_prefix}://{host}:{conf.external_port}/{url_path}"
</code_context>
<issue_to_address>
**Generated IDs break returned links**
When the configured ID charset and length can generate `/`, `.` or `..`, `get_public_url` leaves `/` as a path separator, while clients normalize `.` and `..` path segments. The returned `Location` then points to a different path, so clients cannot retrieve the newly registered service there.
Encode generated IDs as individual path segments and reject `.` and `..` before registering the service.
Also at `cloud_registry/ga4gh/registry/server.py:196-197`, `cloud_registry/api/additions.openapi.yaml:118`.
</issue_to_address>
### Comment 2
<location path="cloud_registry/utils.py" line_range="72" />
<code_context>
+ Host; IPv6 addresses in brackets, with zone IDs percent-encoded (RFC
+ 6874).
+ """
+ address, _, zone = host.partition("%")
+ try:
+ ipaddress.IPv6Address(address)
</code_context>
<issue_to_address>
**Scoped IPv6 URLs are malformed**
When `external_host` is configured as a bracketed scoped IPv6 address, such as `[fe80::1%eth0]`, `_format_host` partitions the zone before removing the brackets, so `IPv6Address` rejects the partial address and the exception path returns the original host. `get_public_url` then emits a raw `%` in `Location`, which clients cannot reliably use.
Remove the brackets before validating the IPv6 address, then rebuild the bracketed host with the zone delimiter encoded as `%25`.
Also at `cloud_registry/utils.py:76-77`.
</issue_to_address>Sourcery assessment
Approval pending. 2 findings to address first.
Blocking findings: cloud_registry/utils.py:56, cloud_registry/utils.py:72
Reject ID character sets with `/` or only dots, generate new IDs instead of `.` and `..`, and accept bracketed IPv6 hosts with zone IDs in the public URL configuration. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
New services are answered with
201 Created(#78).POST /servicesreturns201with aLocationheader pointing to the new service;PUT /services/{serviceId}returns201withLocationwhen it registers a new service, and200when it replaces one. The body is still the service identifier. Errors are unchanged (noLocation; the owner rollback still returns400/500).get_public_url(), builds them fromcustom.endpoints.service(never from the request'sHost), the proxy prefixapi_path, the app's root path and the percent-encoded path. IPv6 hosts are bracketed (zone IDs encoded). TheLocationpath is the collection path of the request plus the identifier, so it keeps the API base path..and..(also percent-encoded) are rejected onPUT(400), as clients would resolve their URLs elsewhere; generated identifiers can't be dot segments, and ID character sets with/or only dots are rejected at startup.config.dev.yamlsets the public URL tohttp://localhost:8080, so thatLocationheaders work locally.additions.openapi.yaml; GA4GH spec untouched):201responseServiceCreatedwithLocation, sharedServiceIdschema, PUT200(updated) and201.host_name; other deployments must configure them).createService,createServiceWithIdandupdateServicecheckresponse.okand only use the returned identifier.Closes #78.
Breaking changes
POST /services, andPUT /services/{serviceId}for new services, return201 Createdinstead of200 OK.PUT /services/.andPUT /services/..return400; services registered with these identifiers before can be read and deleted, but must be registered again to be updated.Verification
pytest: 243 passed, 100% coverage. New tests:201andLocationforPOSTandPUT(followed toGET),200withoutLocationfor replacements, noLocationon errors (400,409, rollback), proxy prefixes and encoding, dot identifiers, public URL building (prefixes, slashes, encoding, IPv6 hosts and zones).ruff check,ruff format --check,mypy cloud_registry tests: clean.ast-grep scan: clean.gitleaks dir .: no leaks.Locationpath from the collection path, test structure (literal expected URLs, oneLocationassertion), spec schema, README section. Declined: deriving expected URLs in tests from the config (literal values were preferred in round 1, so tests don't share the implementation's logic); a startup warning for the unreachable default host (documented instead)./or only dots rejected, generated./..replaced; bracketed IPv6 hosts with zone IDs); 243 tests, 100% coverage, CI green again.Open questions
None.
🤖 Generated with Claude Code