go: cmd/go: should show error detail from module proxies
When a module proxy returns an error, the go command shows only the HTTP status code.
go get golang.org/x/net@latest: unexpected status (https://<proxy url>/golang.org/x/net/@v/list): 404 Not Found
In many cases the proxy will have more detail to report from the output of go mod download
or go list
. Proxy users should be able to see that; without it it’s very hard to tell if the proxy is broken or if the user made a mistake.
One suggestion was simply to add the response body to the error message if it’s text/plain. Maybe there should be some rules about it being one line, or maybe proxy authors should just use their judgement.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 3
- Comments: 18 (10 by maintainers)
Commits related to this issue
- cmd/go/internal/get: propagate parse errors in parseMetaGoImports The signature of parseMetaGoImports implies that it can return an error, but it has not done so since CL 119675. Restore the missing ... — committed to golang/go by bcmills 5 years ago
- cmd/go/internal/get: propagate server errors if no go-import tags are found Updates #30748 Change-Id: Ic93c68c1c4b2728f383edfdb06371ecc79a6f7b1 Reviewed-on: https://go-review.googlesource.com/c/go/+... — committed to golang/go by bcmills 5 years ago
- cmd/go/internal/modload: propagate errors from Query for missing imports Updates #30748 Updates #28459 Change-Id: I1c34b3dae0bf9361dba0dae66bb868901ecafe29 Reviewed-on: https://go-review.googlesourc... — committed to golang/go by bcmills 5 years ago
- cmd/go/internal/module: in VersionError, do not wrap an existing ModuleError VersionError wraps the given error in a ModuleError struct. If the given error is already a ModuleError for the same path... — committed to golang/go by bcmills 5 years ago
- cmd/go/internal/modfetch: reduce path redundancy in checkMod error reporting Updates #30748 Change-Id: I38a6cdc9c9b488fec579e6362a4284e26e0f526e Reviewed-on: https://go-review.googlesource.com/c/go/... — committed to golang/go by bcmills 5 years ago
- cmd/go/internal/modload: add an Unwrap method on ImportMissingError Jay suggested this in CL 189780, and it seems semantically correct. As far as I can tell this has no impact one way or the other r... — committed to golang/go by bcmills 5 years ago
Typically,
proxy.golang.org
serves the same error text asdirect
mode. Since the default in 1.13 ishttps://proxy.golang.org,direct
, most users will end up with thedirect
error messages.(We got a lot of reports of proxy-related confusion from users who had explicitly set
GOPROXY
on 1.12, but 1.12 does not support the fallback todirect
.)@bcmills, @jayconrod It looks like the related CL series is not going to be able to make the cut for 1.13? (Not sure of right CL(s), but maybe for example CL 189783).
I can understand if the full solution might be too risky, but I wonder if there is some simpler type of solution, or at least mitigation?
For example:
maybe cmd/go could emit some type of generic “consider re-running with GOPROXY=direct” message after a proxy returns a fatal error?
or maybe cmd/go could emit some type of “please visit https://proxy.golang.org/the/bad/uri for additional details”, where the uri corresponds to the one that returned the error status?
or maybe
go get -v
could emit the raw output, and the generic error could instead suggestgo get -v
?or otherwise have cmd/go do something that helps point people towards some type of self-help step?
Here is a sample error message:
Right now, I think that contains the error-causing uri? However, it doesn’t suggest visiting there, and that line doesn’t say “error”, and the key message is often nestled between other messages such that people don’t always focus on the most pertinent line or otherwise recognize it as the real error.
Also, is there something in the release notes currently on how to troubleshoot a proxy error?
I don’t quite have a handle on what classes of errors people are likely to see, but it seems there might be problems that have better errors if running with GOPROXY=direct, but then another class of problems that only occur when using the proxy and hence don’t occur when running with GOPROXY=direct.
CC @myitcv
@sirkon, I don’t think we even need
application/json
support for this.What I have in mind is more like: if the content type is
text/plain
and thecharset
is eitherus-ascii
orutf-8
, show the first N lines up to a total of M characters.