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/internal/web: test script failed when have ipv6 address but no ipv4 address #48575

Closed
awen09 opened this issue Sep 23, 2021 · 2 comments
Closed
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. Testing An issue that has been verified to require only test changes, not just a test failure.
Milestone

Comments

@awen09
Copy link

awen09 commented Sep 23, 2021

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

$ go version
go version go1.16.5 linux/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
TESTGONETWORK="panic"
(when run test in cmd\go\script_test.go)

What did you do?

Hello, I was running 'all.bash' on our pipeline and there were some errors occurred. The error message is:

--- FAIL: TestScript/mod_get_ambiguous_pkg (0.16s)
    script_test.go:213: 
        # Both example.net/ambiguous v0.1.0 and example.net/ambiguous/pkg v0.1.0 exist.
        # 'go mod tidy' would arbitrarily choose the one with the longer path,
        # but 'go mod tidy' also arbitrarily chooses the latest version. (0.000s)
        # From a clean slate, 'go get' currently does the same thing as 'go mod tidy':
        # it resolves the package from the module with the longest matching prefix. (0.163s)
        > go get -d example.net/ambiguous/nested/pkg@v0.1.0
        [stderr]
        panic: use of network: http://[::1]:34413/mod/example.net/@v/v0.1.0.info

I found that the virtual machine doesn't have ipv4 address but have ipv6 address. It seems that this situation has not been considered.

In file cmd\go\internal\web\http.go:

if os.Getenv("TESTGONETWORK") == "panic" && !strings.HasPrefix(url.Host, "127.0.0.1") && !strings.HasPrefix(url.Host, "0.0.0.0") {
	panic("use of network: " + url.String())
}

May I change it to:

if os.Getenv("TESTGONETWORK") == "panic" && !strings.HasPrefix(url.Host, "127.0.0.1") && !strings.HasPrefix(url.Host, "0.0.0.0") &&
	!strings.HasPrefix(url.Host, "[::1]") && !strings.HasPrefix(url.Host, "[::]") {
	panic("use of network: " + url.String())
}

What did you expect to see?

expect all test passed

What did you see instead?

--- FAIL: TestScript/mod_get_ambiguous_pkg (0.16s)
    script_test.go:213: 
        # Both example.net/ambiguous v0.1.0 and example.net/ambiguous/pkg v0.1.0 exist.
        # 'go mod tidy' would arbitrarily choose the one with the longer path,
        # but 'go mod tidy' also arbitrarily chooses the latest version. (0.000s)
        # From a clean slate, 'go get' currently does the same thing as 'go mod tidy':
        # it resolves the package from the module with the longest matching prefix. (0.163s)
        > go get -d example.net/ambiguous/nested/pkg@v0.1.0
        [stderr]
        panic: use of network: http://[::1]:34413/mod/example.net/@v/v0.1.0.info
@awen09 awen09 changed the title cmd\go\internal\web: test script failed when have ipv6 address but no ipv4 address cmd/go/internal/web: test script failed when have ipv6 address but no ipv4 address Sep 23, 2021
@jayconrod jayconrod added NeedsFix The path to resolution is known, but the work has not been done. Testing An issue that has been verified to require only test changes, not just a test failure. labels Sep 23, 2021
@jayconrod jayconrod added this to the Unplanned milestone Sep 23, 2021
@jayconrod
Copy link
Contributor

Rather than using hardcoded addresses, let's use net.IP.IsLoopback.

awen09 added a commit to awen09/go that referenced this issue Sep 28, 2021
The existing implementation lacks consideration of running test on a
machine which has ipv6 address but no ipv4 address. Use net.IP.IsLoopback
and net.IP.IsUnspecified instead of hardcoded addresses.

Fixes: golang#48575
awen09 added a commit to awen09/go that referenced this issue Oct 7, 2021
The existing implementation lacks consideration of running test on a
machine which has ipv6 address but no ipv4 address. Use net.IP.IsLoopback
and net.IP.IsUnspecified instead of hardcoded addresses.

Fixes: golang#48575
@gopherbot
Copy link

Change https://golang.org/cl/354609 mentions this issue: cmd/go/internal/web: improve IP check testing on ipv6 env

@golang golang locked and limited conversation to collaborators Oct 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. Testing An issue that has been verified to require only test changes, not just a test failure.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants