fix(upstream): honor npm and Cargo overrides#200
Open
andrew wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR wires the configured upstream overrides for npm and Cargo into their respective protocol handlers so metadata and artifact downloads are fetched from the configured origins (with sane defaults and trailing-slash normalization).
Changes:
- Pass
cfg.Upstream.NPMintoNewNPMHandler, andcfg.Upstream.Cargo/cfg.Upstream.CargoDownloadintoNewCargoHandler. - Build npm and Cargo artifact download URLs from the handler-configured upstream origins via
GetOrFetchArtifactFromURL. - Add tests to validate that configured upstreams are honored for metadata and downloads.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/server/server.go | Plumbs upstream override config into npm and Cargo handlers at server startup. |
| internal/server/server_test.go | Updates test server setup to match new handler constructor signatures. |
| internal/handler/npm.go | Adds configurable upstream origin and uses it when constructing npm tarball download URLs. |
| internal/handler/npm_test.go | Adds coverage ensuring configured npm upstream is used for metadata and downloads. |
| internal/handler/cargo.go | Adds configurable index/download origins and uses configured download origin for crate downloads. |
| internal/handler/cargo_test.go | Adds coverage ensuring configured Cargo index and download upstreams are used. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
upstream.npminto the npm handler for metadata and tarball requestsupstream.cargoandupstream.cargo_downloadinto the Cargo handlerWhy
The configuration exposed npm and Cargo upstream overrides, but the server did not pass them into either handler. Even when handler metadata origins were changed manually, artifact downloads still used the resolver hard-coded public registries.
Validation
go test -race ./... -count=1go tool golangci-lint run ./...