Repository navigation
feat(cloud-registry): expose problem details - #504
Conversation
RestCloudRegistryProvider threw plain errors built from statusText, which is empty over HTTP/2, and never read the body. Apps couldn't tell 401 from 403, and users didn't learn why a registration failed. - Add CloudRegistryError (status, title, detail, serviceId, problem), thrown by every provider method, with the problem's detail (else the body's message, else the action and status) as the message. - ecc-service-create-failed now also carries status, title, detail, serviceId and the thrown error (cause), read from the error's fields, so custom providers' errors work too; also when the service types can't be loaded. - Export the CloudRegistryProvider interface as a type, so the providers module loads in unbundled ES modules (tests). - Document the errors and the event detail; add tests. Closes #454 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Skip blank fields, leave the status text out of fallback messages (HTTP/2 has none), share the field check with the component, read the explanation of plain objects and strings, and prefix failures to load the service types with that action. Add tests and comments. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideThis PR replaces opaque REST status-text errors with exported structured CloudRegistryError instances, propagates their problem details through service-create failure events, and adds corresponding documentation, regression coverage, and test-runner configuration. Sequence diagram for structured Cloud Registry errorssequenceDiagram
participant Client
participant RestProvider
participant Registry
participant CloudRegistryError
Client->>RestProvider: createService(service)
RestProvider->>Registry: POST /services
Registry-->>RestProvider: Error response with status and problem body
RestProvider->>CloudRegistryError: fromResponse(response, action)
CloudRegistryError->>CloudRegistryError: response.json()
CloudRegistryError-->>RestProvider: CloudRegistryError
RestProvider-->>Client: reject with status, detail, title, serviceId, problem
Sequence diagram for service-create failure event detailssequenceDiagram
participant User
participant ServiceCreate
participant Provider
participant Registry
User->>ServiceCreate: Submit service
ServiceCreate->>Provider: createService(service)
Provider->>Registry: POST /services
Registry-->>Provider: 401, 403, 409, or other error
Provider-->>ServiceCreate: throw error with problem fields
ServiceCreate->>ServiceCreate: failureDetail(error, action)
ServiceCreate-->>User: ecc-service-create-failed with error, status, detail, title, serviceId, cause
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Documentation build overview
|
Turbo runs the packages' tests in parallel, and the wes tests use the default port 8000, so the second runner failed with EADDRINUSE. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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="packages/ecc-client-elixir-cloud-registry/src/providers/errors.ts" line_range="73" />
<code_context>
+ ): Promise<CloudRegistryError> {
+ let problem: ProblemDetails | undefined;
+ try {
+ const body: unknown = await response.json();
+ if (body && typeof body === "object" && !Array.isArray(body)) {
+ problem = body as ProblemDetails;
</code_context>
<issue_to_address>
**Error response bodies can stall failures**
When an upstream or proxy returns an error response whose body is very large or does not finish streaming, `response.json()` reads the entire error body before `fromResponse` returns; a stalled or exceptionally large body therefore keeps provider calls pending or consumes excessive memory, so callers never receive the error and the component never emits its failure event.
Bound error-body reading by size and duration, then fall back to the action-and-status message when a bound is reached.
</issue_to_address>Sourcery assessment
Approval pending. 1 finding to address first.
Blocking findings: packages/ecc-client-elixir-cloud-registry/src/providers/errors.ts:73
Read at most 64 KiB of an error body within 5 seconds, so that a huge or stalled body (e.g. from a proxy) cannot hold up the error; fall back to the action and status otherwise. Co-Authored-By: Claude Opus 5.5 <[email protected]>
anuragxxd
left a comment
There was a problem hiding this comment.
Thanks, Alex. Approving; I'm merging this next, once CI passes.
To save you the rebase after #502, I merged dev into the branch:
web-test.runner-config.mjs: the only conflict. I kept your comment that tests must run from the package directory.service-create.tsmerged cleanly: #502's check for late answers and yourfailureDetail()now sit together in the type-loading error branch.- 5081045: #502's test "drops the old types if the new provider fails" still expected the fixed message
Failed to load service types. It now expectsFailed to load service types: unauthorized, the message this PR is meant to produce.
All 34 cloud-registry tests pass locally in Chromium, Firefox and WebKit, and lint and build pass.
Sourcery withdrew this approval because the latest commits introduced blocking findings.
Resolve the conflicts in service-create.ts: keep the type picker and its type status and reloads, on dev's provider handling (#502) and problem details (#504); drop the duplicate typesRequest field. Adapt dev's new service-create tests to the type picker: fillForm chooses "Add new service type", and the provider tests expect the reload of the types after a create. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve the conflicts in service-create.ts and its docs: keep the validation, environments and URL schemes; dev's provider handling (#502) now loads the registration rules too, and resets them without a provider. The event table takes dev's failure details (#504) and the PR's validation details. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Description
RestCloudRegistryProviderthrew plain errors built fromresponse.statusText(empty over HTTP/2, so messages read "Failed to create service: ") and never read the body. Apps couldn't tell401(log in) from403(no role on the service), and the create component's users didn't learn why a registration failed, although the registry explains every error as problem details. The Cloud Registry UI works around this in its own provider and by wrapping the provider on its create page to recover the error behindecc-service-create-failed.CloudRegistryError(exported from@elixir-cloud/cloud-registry/providers, with theProblemDetailstype): extendsErrorand hasstatus,title,detail,serviceIdandproblem(the whole JSON body). Every method ofRestCloudRegistryProviderthrows it for error statuses. The body is read whatever its content type (alsoapplication/problem+json; proxies may send HTML). The message is the problem'sdetail, else amessagefield, else the action and the status, e.g. "Failed to create service (502)". Blank fields count as missing. Error bodies are read only up to 64 KiB (MAX_PROBLEM_BYTES) and for at most 5 s (PROBLEM_TIMEOUT_MS), so a huge or stalled body from a proxy can't hold up the error.ecc-service-create-failednow also carriesstatus,title,detail,serviceIdandcause(the thrown error), next toerror. They are read from the error's fields, so custom providers that throw errors with these fields (as the Cloud Registry UI's does) work too. Thrown strings and plain objects withdetail/messagegive a usefulerroras well.errorwas the fixed "Failed to load service types"; it is now "Failed to load service types: " (the reason if there is one), with the status and problem details. Code that compares the whole string must check its start instead.providers/index.tsexports theCloudRegistryProviderinterface withexport type; as a value export, browsers loading the unbundled modules (the tests) fail to import the module. No change for bundled consumers, since it is an interface.message, blank and wrongly typed fields, status text), and the event forCloudRegistryErrors, custom errors, strings, plain objects and failed type loads, plus too large and stalled error bodies (23 cases). Adds the package'stestscript and thetsconfigoption of the shared test config, as fix(cloud-registry): react to provider changes #502 and feat: add surface, font and dark mode controls #446 do.Closes #454
How it was verified
npm run lint: 0 errors (warnings unchanged).npm run build(cloud-registry and dependencies, and the docs site).npx web-test-runner --group defaultinpackages/ecc-client-elixir-cloud-registrywith Chromium and Firefox: 23/23 pass;westests still pass with the changed shared config. WebKit can't start on my machine; CI runs it.--port 8002(also in fix(cloud-registry): react to provider changes #502). After the Sourcery fix (bounded body reader), CI passed again.Checklist
Comments
loadServiceTypes()'s error branch, the package'stestscript and the shared test config (same lines). I'll mergedevinto whichever lands second. Highlighting the field named in a400inside the form is feat(cloud-registry): validate the create form like the API #453 (another PR).@elixir-cloud/service-registry's provider still throws plain errors; feat(cloud-registry): expose problem details on errors #454 is about the Cloud Registry provider. It can follow the same pattern later if wanted.Declined review findings
action) to tell a failed type load from a failed registration: the prefix oferrortells them apart, and the event already exists for both cases. Easy to add if you prefer a field.tsconfig: "./tsconfig.json"is relative to the working directory, so tests must run from a package directory (as alltestscripts do); documented in a comment.204on delete) still reject with aSyntaxError: older than this branch, not part of feat(cloud-registry): expose problem details on errors #454.🤖 Generated with Claude Code
Summary by Sourcery
Expose structured Cloud Registry errors and propagate actionable problem details through service creation failure events.
New Features:
CloudRegistryErrorandProblemDetailstypes.ecc-service-create-failedevents for registration and service-type loading failures.Bug Fixes:
Enhancements:
CI:
Documentation:
Tests: