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

cmd/go: go list -json does not return json on error #30755

Open
marwan-at-work opened this Issue Mar 12, 2019 · 2 comments

Comments

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

marwan-at-work commented Mar 12, 2019

What version of Go are you using (go version)?

$ go version
go 1.12 darwin

Does this issue reproduce with the latest release?

Yes

What did you do?

GO111MODULE=on go list -m -versions -json github.com/golang/nonexistentrepo@latest

What did you expect to see?

A valid json output with a clear error in the Error field. Something similar to when go mod download has an error as such:

{
  "Error": "repository not found"
}

What did you see instead?

A non json output as such (modified):

go list -m github.com/golang/nonexistentrepo: git ls-remote -q origin in /Users/me/go/pkg/mod/cache/vcs/xxx-long-sha: exit status 128:
	remote: Repository not found.
	fatal: repository 'https://github.com/golang/nonexistentrepo/' not found
@bcmills

This comment has been minimized.

Copy link
Member

bcmills commented Mar 12, 2019

Is that on stdout, or on stderr?

(See previously #26218 (comment).)

CC @jayconrod

@marwan-at-work

This comment has been minimized.

Copy link
Contributor Author

marwan-at-work commented Mar 12, 2019

@bcmills stderr I believe. Regarding the comment you linked, with the same exact "error" go mod download has an almost opposite behavior: nothing logged to stderr, and you get a valid json with an Error field inside of it. Though the error field is inaccurate (different, but related issue).

For example

GO111MODULE=on go mod download -json github.com/golang/nonexistentrepo@latest

returns

{
	"Path": "github.com/golang/nonexistentrepo",
	"Version": "latest",
	"Error": "invalid version \"latest\""
}
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.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.