Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/go: in 'go list -m', ignore "not found" errors loading updates
"Not found" and "no matching version" errors usually indicate the user is offline or the proxy doesn't have a version of go.mod that could provide retractions. 'go list -m -u' should still succeed. We should still report unclassified errors though. Previously, we reported most errors loading retractions but did not report errors loading updates. This change makes those operations more consistent. Fixes #45305 Change-Id: I2f23a566c9481bc7ff229a177f39d78f6a8aae77 Reviewed-on: https://go-review.googlesource.com/c/go/+/306572 Trust: Jay Conrod <jayconrod@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com> Reviewed-by: Michael Matloob <matloob@golang.org>
- Loading branch information
Jay Conrod
committed
Apr 8, 2021
1 parent
0e09e41
commit 23e1d36
Showing
4 changed files
with
103 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Check that if a proxy does not have a version of a module that could be | ||
# an upgrade, 'go list -m -u' still succeeds. | ||
# We use a local file proxy, since our test proxy doesn't have the behavior | ||
# we want to test, and we don't want it to be too clever. | ||
# Verifies #45305, where proxy.golang.org serves an empty /@v/list (200) | ||
# but has no /@latest (410) because the go.mod at the tip of the default | ||
# branch has a different major version suffix. | ||
env testproxy=$GOPROXY | ||
env GOPROXY=file://$WORK/proxy | ||
env GOSUMDB=off | ||
|
||
# If the proxy does not return a list of versions (404/410) | ||
# or a latest version (404/410), we should see no error. | ||
go list -m example.com/noversion | ||
stdout '^example.com/noversion v0.0.0$' | ||
go list -m -u example.com/noversion | ||
stdout '^example.com/noversion v0.0.0$' | ||
|
||
# If the proxy returns an empty list of versions (200, not 404/410) | ||
# but does not have a latest version (404/410), we should see no error. | ||
go list -m example.com/nolatest | ||
stdout '^example.com/nolatest v0.0.0$' | ||
go list -m -u example.com/nolatest | ||
stdout '^example.com/nolatest v0.0.0$' | ||
|
||
# If proxy returns an invalid response, we should see an error. | ||
env GOPROXY=$testproxy/invalid | ||
! go list -m -u example.com/nolatest | ||
stderr '^go list -m: loading module retractions for example.com/nolatest@v0.0.0: invalid response from proxy "[^"]*": invalid character ''i'' looking for beginning of value$' | ||
|
||
-- go.mod -- | ||
module m | ||
|
||
go 1.17 | ||
|
||
require ( | ||
example.com/nolatest v0.0.0 | ||
example.com/noversion v0.0.0 | ||
) | ||
-- go.sum -- | ||
example.com/nolatest v0.0.0/go.mod h1:HnLrCt6SJga5tCtJ7IzG9dOOCniY3G5C0VT7jfMdS0M= | ||
example.com/noversion v0.0.0/go.mod h1:2RUfWiCYsygSXPM2Igxx0FD3Kq33OnVdxm34eDDhXbQ= | ||
-- $WORK/proxy/example.com/nolatest/@v/list -- | ||
-- $WORK/proxy/example.com/nolatest/@v/v0.0.0.info -- | ||
{"Version":"v0.0.0"} | ||
-- $WORK/proxy/example.com/nolatest/@v/v0.0.0.mod -- | ||
module example.com/nolatest | ||
|
||
go 1.17 | ||
-- $WORK/proxy/example.com/noversion/@v/v0.0.0.info -- | ||
{"Version":"v0.0.0"} | ||
-- $WORK/proxy/example.com/noversion/@v/v0.0.0.mod -- | ||
module example.com/noversion | ||
|
||
go 1.17 |
This file contains 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