Skip to content

fix(go): return 404 for missing modules#196

Merged
andrew merged 1 commit into
git-pkgs:mainfrom
ychampion:fix-go-proxy-not-found-status
Jul 12, 2026
Merged

fix(go): return 404 for missing modules#196
andrew merged 1 commit into
git-pkgs:mainfrom
ychampion:fix-go-proxy-not-found-status

Conversation

@ychampion

Copy link
Copy Markdown
Contributor

Summary

  • return HTTP 404 when the upstream Go module mirror reports a missing artifact
  • keep other upstream failures at 502 and cover both status paths

Why

Go only advances from GOPROXY=<proxy>,direct when 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 ./...

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ErrNotFound from GetOrFetchArtifact to 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.

Comment thread internal/handler/go.go Outdated
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.
@ychampion ychampion force-pushed the fix-go-proxy-not-found-status branch from 43646a3 to 5b959d1 Compare July 12, 2026 18:48

@andrew andrew left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed: the not-found sentinel is preserved as HTTP 404 while other upstream failures remain 502; focused regression coverage passes.

@andrew andrew merged commit 23364bd into git-pkgs:main Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Go: should respond with 404 when artifact not found

3 participants