Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: cmd/go: return parseable errors for mod download #30725

Closed
marwan-at-work opened this issue Mar 11, 2019 · 4 comments

Comments

Projects
None yet
4 participants
@marwan-at-work
Copy link
Contributor

commented Mar 11, 2019

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:

  1. Repository not found
  2. The requested version does not exist
  3. Authentication failure for private modules
  4. 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?

  1. go mod download -json bad/path@latest
  2. go mod download -json bad/path@v0.9.0
  3. go mod download -json github.com/gomods/moduledoesnotexist@latest
  4. go mod download -json github.com/gomods/moduledoesnotexist@v0.9.0

What did you expect to see?

  1. Reliable code or message to say it's a bad module path
  2. Reliable code or message to say it's a bad module path.
  3. Reliable code or message to say that the module does not exist.
  4. Reliable code or message to say that the module does not exist.

What did you see instead?

  1. 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\""
}
  1. 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)"
}
  1. Incorrect error message same as no.1
{
	"Path": "github.com/gomods/moduledoesnotexist",
	"Version": "latest",
	"Error": "invalid version \"latest\""
}
  1. 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"
}

@mikioh mikioh changed the title [Proposal] cmd/go: return parseable errors for mod download Proposal: cmd/go: return parseable errors for mod download Mar 11, 2019

@gopherbot gopherbot added this to the Proposal milestone Mar 11, 2019

@gopherbot gopherbot added the Proposal label Mar 11, 2019

@bcmills

This comment has been minimized.

Copy link
Member

commented Mar 11, 2019

Dup of #30134.

@bcmills bcmills closed this Mar 11, 2019

@marwan-at-work

This comment has been minimized.

Copy link
Contributor Author

commented Mar 11, 2019

@bcmills the duplicate issue does not mention the inaccuracy of error messages that I stated above. Should I comment about them there, open a new issue, or are they not considered a problem?

Thanks!

@jayconrod

This comment has been minimized.

Copy link
Contributor

commented Mar 11, 2019

@marwan-at-work Inaccurate error messages are definitely a problem. Could you please open a new issue about inaccurate go mod download errors specifically, and cc me?

@marwan-at-work

This comment has been minimized.

Copy link
Contributor Author

commented Mar 11, 2019

@jayconrod done, thanks! #30743

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.