}
type proxyRepo struct {
- url *url.URL
- path string
+ url *url.URL
+ path string
+ redactedURL string
}
func newProxyRepo(baseURL, path string) (Repo, error) {
if err != nil {
return nil, err
}
-
+ redactedURL := base.Redacted()
base.Path = strings.TrimSuffix(base.Path, "/") + "/" + enc
base.RawPath = strings.TrimSuffix(base.RawPath, "/") + "/" + pathEscape(enc)
- return &proxyRepo{base, path}, nil
+ return &proxyRepo{base, path, redactedURL}, nil
}
func (p *proxyRepo) ModulePath() string {
}
info := new(RevInfo)
if err := json.Unmarshal(data, info); err != nil {
- return nil, p.versionError(rev, err)
+ return nil, p.versionError(rev, fmt.Errorf("invalid response from proxy %q: %w", p.redactedURL, err))
}
if info.Version != rev && rev == module.CanonicalVersion(rev) && module.Check(p.path, rev) == nil {
// If we request a correct, appropriate version for the module path, the
}
info := new(RevInfo)
if err := json.Unmarshal(data, info); err != nil {
- return nil, p.versionError("", err)
+ return nil, p.versionError("", fmt.Errorf("invalid response from proxy %q: %w", p.redactedURL, err))
}
return info, nil
}
}
path := r.URL.Path[len("/mod/"):]
+ // /mod/invalid returns faulty responses.
+ if strings.HasPrefix(path, "invalid/") {
+ w.Write([]byte("invalid"))
+ return
+ }
+
// /mod/quiet/ does not print errors.
quiet := false
if strings.HasPrefix(path, "quiet/") {
--- /dev/null
+env GO111MODULE=on
+env GOPROXY=$GOPROXY/invalid
+
+! go list -m rsc.io/quote@latest
+stderr '^go list -m: module rsc.io/quote: invalid response from proxy "'$GOPROXY'": invalid character ''i'' looking for beginning of value$'
+
+! go list -m rsc.io/quote@1.5.2
+stderr '^go list -m: rsc.io/quote@1.5.2: invalid version: invalid response from proxy "'$GOPROXY'": invalid character ''i'' looking for beginning of value$'
chmod 0000 $WORK/gatekeeper/example.com/join/subpkg/@latest
cp go.mod.orig go.mod
! go get -d example.com/join/subpkg
-stderr 'go get example.com/join/subpkg: module example.com/join/subpkg: (invalid character .+|reading file://.*/gatekeeper/example.com/join/subpkg/@latest: .+)'
+stderr 'go get example.com/join/subpkg: module example.com/join/subpkg: (invalid response from proxy ".+": invalid character .+|reading file://.*/gatekeeper/example.com/join/subpkg/@latest: .+)'
-- go.mod.orig --
module example.com/othermodule