fix(go): return 404 for missing modules#196
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adjusts the Go module zip download handler to return HTTP 404 when the upstream fetch reports a missing artifact, enabling the Go toolchain’s GOPROXY=<proxy>,direct fallback behavior described in issue #184.
Changes:
- Map
fetch.ErrNotFoundfromGetOrFetchArtifactto an HTTP 404 response in the Go handler. - Add a table-driven test covering both the 404 (not found) and 502 (other upstream failures) paths.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| internal/handler/go.go | Returns 404 for upstream “not found” sentinel errors while keeping other failures as 502. |
| internal/handler/go_test.go | Adds test coverage for the new 404 vs 502 status mapping behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Return the repository-standard not-found response when an upstream module is absent. Constraint: GOPROXY advances to direct only after 404 or 410 responses. Rejected: Preserve a handler-specific response body | sibling handlers consistently use not found. Confidence: high Scope-risk: narrow Directive: Keep missing-artifact responses consistent across registry handlers. Tested: go test ./internal/handler -run TestGoModuleDownloadUpstreamErrors -count=1; prior go test -race ./...; go build ./...; golangci-lint; go vet.
43646a3 to
5b959d1
Compare
andrew
approved these changes
Jul 12, 2026
andrew
left a comment
Contributor
There was a problem hiding this comment.
Reviewed: the not-found sentinel is preserved as HTTP 404 while other upstream failures remain 502; focused regression coverage passes.
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
Why
Go only advances from
GOPROXY=<proxy>,directwhen the proxy responds with 404 or 410. The handler was turning the upstream not-found sentinel into 502, which prevented the documented fallback. Fixes #184.Validation
go test -race ./...go build ./...go tool golangci-lint run ./...go vet ./...