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: clarify error for invalid proxy responses #38680

Closed
homelchenko opened this issue Apr 26, 2020 · 9 comments
Closed

cmd/go: clarify error for invalid proxy responses #38680

homelchenko opened this issue Apr 26, 2020 · 9 comments
Labels
FrozenDueToAge help wanted modules NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@homelchenko
Copy link

homelchenko commented Apr 26, 2020

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

$ go version
go version go1.14.2 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/hennadii/Library/Caches/go-build"
GOENV="/Users/hennadii/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=
GOOS="darwin"
GOPATH="/Users/hennadii/code/golang"
GOPRIVATE=""
GOPROXY=
GOROOT="/usr/local/Cellar/go/1.14.2_1/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.14.2_1/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
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/2j/23_h2scj481d4l34mjxwpsyr0000gn/T/go-build221808420=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Originally, tried to install tools in VS Code, but later narrowed it down to installing this package

go get rsc.io/quote

(in module, not on GOPATH)

I do have GOPROXY pointing at 'private' server, and I get the error when that server is not reachable due to networking. Go commands start working again as expected when connectivity is restored

What did you expect to see?

Some error hinting at problems with proxy accessibility

What did you see instead?

go get rsc.io/quote: module rsc.io/quote: invalid character 'e' looking for beginning of value

@smasher164 smasher164 changed the title invalid character 'e' looking for beginning of value when GOPROXY is not accessible cmd/go: unclear error when proxy is not accessible Apr 27, 2020
@smasher164 smasher164 added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. modules labels Apr 27, 2020
@smasher164
Copy link
Member

@bcmills @jayconrod @matloob

@jayconrod
Copy link
Contributor

I couldn't reproduce this. Tried a few different things:

When offline, with default GOPROXY:

go get rsc.io/quote: module rsc.io/quote: Get "https://proxy.golang.org/rsc.io/quote/@v/list": dial tcp: lookup proxy.golang.org: no such host

When offline, with GOPROXY=direct:

go get rsc.io/quote: unrecognized import path "rsc.io/quote": https fetch: Get "https://rsc.io/quote?go-get=1": dial tcp: lookup rsc.io: no such host

Online, with GOPROXY referring to a non-existent host:

go get rsc.io/quote: module rsc.io/quote: Get "https://does.not.exist/rsc.io/quote/@v/list": dial tcp: lookup does.not.exist: no such host

@homelchenko Could you post your GOPROXY setting? It wasn't included in the go env output. Could you tell us more about the proxy itself, too?

The string looking for beginning of value appears in encoding/json. Just taking a wild guess, the proxy may have served invalid JSON on the $module/@v/$version.info or $module/@latest endpoints.

@jayconrod jayconrod added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Apr 27, 2020
@homelchenko
Copy link
Author

Right, I specifically cut off GOPROXY settings as it contains a reference to 'private' goproxy based on athens, and I'd rather not post it on public issue tracker :sorry:

To add to my setup: there's this Athens instance, which is on internal network, and my GOPROXY points to it via some subdomain. When I am not on VPN these days, I get the error I described above. However, now that I pinged the proxy, it looks like it is reachable, it might be I get some 'other' response from athens while not on VPN

@homelchenko
Copy link
Author

homelchenko commented Apr 27, 2020

Okay, having done a few more experiments, I seem to understand more why i can see that 'e' letter in the error. So, under those circumstances when I am not on vpn, what server responds to '< proxy >/rsc.io/quote/@v/list/ is not html containing list of available versions, but with some dummy text starting with 'e'.

Looks like the root cause

@jayconrod jayconrod changed the title cmd/go: unclear error when proxy is not accessible cmd/go: clarify error for invalid proxy responses Apr 27, 2020
@jayconrod jayconrod added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Apr 27, 2020
@jayconrod jayconrod added this to the Backlog milestone Apr 27, 2020
@jayconrod
Copy link
Contributor

Ok cool, I've changed the issue title to indicate we should clarify these error messages.

Out of curiosity, could you post the proxy response containing the dummy text?

@homelchenko
Copy link
Author

HTTP/1.1 0 Unknown
content-length: 11
content-type: text/plain
date: Mon, 27 Apr 2020 16:59:09 GMT
server: envoy

empty token

@mlowicki
Copy link
Contributor

mlowicki commented May 8, 2020

I'll take a look at this issue.

@mlowicki
Copy link
Contributor

mlowicki commented May 9, 2020

I was able to reproduce it on my machine with:

$ GOPROXY=http://localhost:8000 go get rsc.io/quote
go get rsc.io/quote: module rsc.io/quote: invalid character 'x' looking for beginning of value

server:

package main

import (
        "fmt"
        "net/http"
)

func main() {
        http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
                fmt.Fprintf(w, "x")
        })
        err := http.ListenAndServe("localhost:8000", nil)
        if err != nil {
                panic(err)
        }
}

For the record, returning status code 0 as mentioned in #38680 (comment) triggers other error:

$ GOPROXY=http://localhost:8000 go get rsc.io/quote
go get rsc.io/quote: module rsc.io/quote: Get "http://localhost:8000/rsc.io/quote/@v/list": net/http: HTTP/1.x transport connection broken: malformed HTTP status code "0"

I'll work now on improving error messages.

@gopherbot
Copy link

Change https://golang.org/cl/233437 mentions this issue: cmd/go: clarify error for invalid proxy responses

@golang golang locked and limited conversation to collaborators Aug 21, 2021
@dmitshur dmitshur modified the milestones: Backlog, Go1.16 Oct 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge help wanted modules NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

7 participants