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: malformed file path error not bubbled up #34539

Closed
padurean opened this issue Sep 25, 2019 · 4 comments
Closed

cmd/go: malformed file path error not bubbled up #34539

padurean opened this issue Sep 25, 2019 · 4 comments
Milestone

Comments

@padurean
Copy link

@padurean padurean commented Sep 25, 2019

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

$ go version
go1.13 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/ogg/Library/Caches/go-build"
GOENV="/Users/ogg/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/ogg/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.13/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.13/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/7c/2189p7097pzgjmhz046qms940000gn/T/go-build760274827=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

$ export GO111MODULE=on
$ go mod init
$ go get github.com/rubanbydesign/rest
    go: finding github.com/rubanbydesign/rest latest
    go get github.com/rubanbydesign/rest: no matching versions for query "upgrade"

What did you expect to see?

success (i.e. no error)

What did you see instead?

go get github.com/rubanbydesign/rest: no matching versions for query "upgrade"

NOTE: With export GO111MODULE=off go get github.com/rubanbydesign/rest succeeds.

@agnivade

This comment has been minimized.

Copy link
Contributor

@agnivade agnivade commented Sep 26, 2019

Wow, the real error message is way hidden.

First off, normal go get doesn't show anything:

$go get -v github.com/rubanbydesign/rest
go: finding github.com/rubanbydesign/rest latest
go get github.com/rubanbydesign/rest: no matching versions for query "upgrade"

Let's try with no proxy:

$GOPROXY=direct go get -v github.com/rubanbydesign/rest
go: finding github.com/rubanbydesign/rest latest
go: downloading github.com/rubanbydesign/rest v0.0.0-20190925204409-a9714d13f578
verifying github.com/rubanbydesign/rest@v0.0.0-20190925204409-a9714d13f578: github.com/rubanbydesign/rest@v0.0.0-20190925204409-a9714d13f578: reading https://sum.golang.org/lookup/github.com/rubanbydesign/rest@v0.0.0-20190925204409-a9714d13f578: 410 Gone

Hmm .. okay the commit is lost somehow or something bad happened ? The github repo looks fine. Let's try with no sumdb:

$GOPROXY=direct GOSUMDB=off go get -v github.com/rubanbydesign/rest
go: finding github.com/rubanbydesign/rest latest
go: downloading github.com/rubanbydesign/rest v0.0.0-20190925204409-a9714d13f578
go: extracting github.com/rubanbydesign/rest v0.0.0-20190925204409-a9714d13f578
-> unzip /home/agniva/play/go/pkg/mod/cache/download/github.com/rubanbydesign/rest/@v/v0.0.0-20190925204409-a9714d13f578.zip: malformed file path "user_test.go'": invalid char '\''
go get github.com/rubanbydesign/rest: unzip /home/agniva/play/go/pkg/mod/cache/download/github.com/rubanbydesign/rest/@v/v0.0.0-20190925204409-a9714d13f578.zip: malformed file path "user_test.go'": invalid char '\''

Aha ! So it's because of a trailing ' in user_test.go'. But the previous commands have no indication whatsoever.

@bcmills @jayconrod - Is there some open issue which somehow tracks bubbling up this error message in the default go get ?

@agnivade agnivade changed the title go get github.com/rubanbydesign/rest: no matching versions for query "upgrade" cmd/go: malformed file path error not bubbled up Sep 26, 2019
@agnivade agnivade added this to the Go1.14 milestone Sep 26, 2019
@padurean

This comment has been minimized.

Copy link
Author

@padurean padurean commented Sep 26, 2019

@agnivade 😲 Wow! That was a nasty little one. I've removed that user_test.go' file as it was just garbage anyway (it had no content) and now go get succeeds. Thank you very much! Of course, the bubbling up of the error message is still a nice-to-have fix 🙂

@jayconrod

This comment has been minimized.

Copy link
Contributor

@jayconrod jayconrod commented Sep 26, 2019

@agnivade Wow, that's pretty obscure. We should definitely surface that better. In general, errors where we aren't able to produce a module zip aren't well reported.

@jayconrod

This comment has been minimized.

Copy link
Contributor

@jayconrod jayconrod commented Oct 1, 2019

It looks like this is already mitigated at tip, so I'll close this as a duplicate of #30748.

verifying github.com/rubanbydesign/rest@v0.0.0-20190925204409-a9714d13f578/go.mod: github.com/rubanbydesign/rest@v0.0.0-20190925204409-a9714d13f578/go.mod: reading https://sum.golang.org/lookup/github.com/rubanbydesign/rest@v0.0.0-20190925204409-a9714d13f578: 410 Gone
	server response: not found: unzip /tmp/gopath/pkg/mod/cache/download/github.com/rubanbydesign/rest/@v/v0.0.0-20190925204409-a9714d13f578.zip: malformed file path "user_test.go'": invalid char '\''

Internally, the go command is successfully creating a module zip file, but it fails validation when we try to extract it. I don't believe there's any case where we create a zip file without extracting it, so while it may be a good idea to add some validation to the zip creation code, it wouldn't have any visible change.

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