fix(api): surface cross-DB invariant breakages as 4xx, not 500#101
Merged
Conversation
The supply-chain and aggregate endpoints returned 500 when a process id was parseable but absent from the matrix index, or when a matrix solve failed. Those are client-submitted invariant breakages, so they now map to 422 like the rest of the cross-DB pipeline. Introduces a pure serviceErrorToServerError mapping so the status contract is unit-testable without booting a server, makes validateUUID return the parsed UUID (callers no longer re-parse), and states the expected activity_uuid_product_uuid format in the InvalidProcessId body. These changes were meant to ship with the #87 cleanup sweep but were left uncommitted.
The [Unreleased] entry described work not in this PR: MatrixError already mapped to 422 on main, the fixed-string "Invalid ProcessId format" bodies are still present, and the OpenAPI schema alignment lives in earlier commits. Trim it to what this PR actually changes — InvalidUUID 500->400, FlowNotFound 500->404. Also drop the stale "Translate a Service-level error" Haddock block left stacked above serviceErrorToServerError's own doc comment.
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.
What
The
ServiceError → HTTP statusmapping had two constructors falling through to HTTP 500:InvalidUUIDandFlowNotFound. Both are client-supplied invariant breakages, so they now return 400 and 404 respectively — noServiceErrormaps to 5xx anymore.Also in this slice:
serviceErrorToServerErrormapping, so theServiceError → HTTP statuscontract is unit-testable without booting a server (RoutesSpecnow has a platform-independent regression guard).validateUUIDreturns the parsedUUIDinstead of the original text, removing a double-parse (and a now-unreachable error branch) inwithValidatedFlow.Data.Validationhelpers (fromEither,success), a comment fix inAPI.Types, an exhaustiveness comment inMethod.Mapping, and whitespace inDatabaseHandlers.Why
These were meant to land with the #87 behavior-preserving cleanup sweep but were left uncommitted in the working tree. This is the behavior-changing part (status codes), so it's split out into its own PR.
Tests
cabal test→ 1114 examples, 0 failures. NewCrossDBLinkingStatsSemigroup/Monoid tests and theserviceErrorToServerErrorstatus-contract tests included.