Skip to content

codeartifact: normalize Cargo metadata accepts - #4

Merged
ravi-pplx merged 1 commit into
pplx/mainfrom
ravi/cachew-cargo-text-accept
Sep 1, 2026
Merged

codeartifact: normalize Cargo metadata accepts#4
ravi-pplx merged 1 commit into
pplx/mainfrom
ravi/cachew-cargo-text-accept

Conversation

@ravi-pplx

Copy link
Copy Markdown

Why

Cargo sparse-index clients request config.json with Accept: text/plain. Forwarding that header to CodeArtifact produces a non-JSON representation, so Cachew rejects the response and returns 502 CodeArtifact origin unavailable. This prevents native Cargo from using Cachew as an unauthenticated CodeArtifact proxy.

What changed

  • Normalize Cargo metadata origin requests to Accept: application/json before rewriting the response.
  • Apply the same normalization when metadata follows a cross-origin redirect.
  • Preserve caller-selected Accept variants for all other package formats.
  • Cover native Cargo's request shape and the redirect path with regression tests.

Impact

Cargo config.json responses remain rewritten to Cachew download/API URLs with auth-required: false; other CodeArtifact package formats are unchanged.

Cargo sparse clients request config.json with Accept: text/plain, which makes CodeArtifact return a representation that Cachew cannot safely rewrite as JSON. Normalize Cargo metadata origin requests to application/json, including cross-origin redirects, while preserving the caller Accept header for other package formats.

Verification: go test ./... -race -timeout 180s
@ravi-pplx
ravi-pplx marked this pull request as ready for review September 1, 2026 03:31
@ravi-pplx
ravi-pplx merged commit d5345dc into pplx/main Sep 1, 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.

1 participant