Closed
Description
Summary
Per @rsc 's comment, all proxies must use go mod download
to ensure checksums are consistent amongst each other.
Therefore, Proxies that try to download modules through the go command should be able to understand errors in a programmatic way without having to parse text. Such errors can be:
- Repository not found
- The requested version does not exist
- Authentication failure for private modules
- Incorrect module path (does not begin with host name)
go mod download
takes a -json
flag which includes an Error string inside of it. I propose that we include an ErrorCode
or at the very least be confident that the Error
strings will be locked and not changed without notice.
Furthermore, some of the messages in the Error field are inaccurate, see below for details.
What version of Go are you using (go version
)?
$ go version go version go1.12 darwin/amd64
Does this issue reproduce with the latest release?
Yes
What did you do?
go mod download -json bad/path@latest
go mod download -json bad/[email protected]
go mod download -json github.com/gomods/moduledoesnotexist@latest
go mod download -json github.com/gomods/[email protected]
What did you expect to see?
- Reliable code or message to say it's a bad module path
- Reliable code or message to say it's a bad module path.
- Reliable code or message to say that the module does not exist.
- Reliable code or message to say that the module does not exist.
What did you see instead?
- Incorrect error message: it should prioritize saying that the module path is incorrect rather than that the version invalid. In fact,
latest
is not invalid.
{
"Path": "github.com/gomods/moduledoesnotexist",
"Version": "latest",
"Error": "invalid version \"latest\""
}
- Correct error message, comparing against no.1 above, but it might be helpful to lock the message or introduce an error code.
{
"Path": "bad/path",
"Version": "v0.9.0",
"Error": "unrecognized import path \"bad/path\" (import path does not begin with hostname)"
}
- Incorrect error message same as no.1
{
"Path": "github.com/gomods/moduledoesnotexist",
"Version": "latest",
"Error": "invalid version \"latest\""
}
- Inaccurate error message: it should tell us that the Repository is not found, instead of "invalid revision"
{
"Path": "github.com/gomods/moduledoesnotexist",
"Version": "v0.9.0",
"Error": "unknown revision v0.9.0"
}