Accept 2xx (including 201 Created) from Registry API on publish - #1417
Open
m-rinaldi wants to merge 1 commit into
Open
Accept 2xx (including 201 Created) from Registry API on publish#1417m-rinaldi wants to merge 1 commit into
m-rinaldi wants to merge 1 commit into
Conversation
thomashoneyman
approved these changes
Aug 15, 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.
Problem
Running
spago publishfails at the very last step even though the publish request succeeds. The registry responds with HTTP201and a valid job payload, but spago reports it as an error:The job is actually created in the registry – spago just refuses to continue polling the job logs.
Cause
In
callRegistry(Registry.purs), any response whose status was not exactly200was treated as a failure:Just (Right { status, text }) | status /= 200 -> ... -- error branchThe registry API distinguishes job creation from a duplicate submission by HTTP status:
201 Createdfor a newly created job and200 OKfor an existing/duplicate job. The registry's own client accepts both (seepurescript/registry-dev,submitJob/JobSubmissionResult: "the HTTP status distinguishes whether the server created a job (201) or returned an existing duplicate (200)" – its check isresponse.status == 200 || response.status == 201). Both are success responses carrying the same{ jobId }body, but spago only accepted200.Fix
Treat any 2xx status as success:
Just (Right { status, text }) | status < 200 || status >= 300 -> ... -- error branchThis correctly handles both the
201(new job) and200(duplicate) cases, after which spago proceeds to poll the job logs as intended.Testing
npm run format:check(purs-tidy) – all files formatted.spago build– succeeds.spago test -p spago -- --example "publish"– 18/18 pass (no regressions).No new automated test is included: the existing publish tests are integration tests that stop before a live registry call,
baseApiis hardcoded with no injection seam, and a faithful test would require a mock registry server (out of scope for a one-line status-range fix). The correctness is established by the registry's documented status semantics and its own client's handling (submitJob), linked above.Checklist:
README(N/A – bugfix)