go: cmd/go: "v1.x.y is not a tag" when .gitconfig sets `log.decorate` to `full`

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

$ go version
go version go1.16.14 darwin/amd64

Does this issue reproduce with the latest release?

yes

Not Reproduced: go1.14.15, go1.15.15, go1.18beta2
go1.16.13, go1.17.6

Reproduced: go1.16.14, go1.17.7, go1.18rc1

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

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN="/Users/work/go/bin"
GOCACHE="/Users/work/Library/Caches/go-build"
GOENV="/Users/work/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/work/go/pkg/mod"
GONOPROXY="*mydomain.com*"
GONOSUMDB="*"
GOOS="darwin"
GOPATH="/Users/work/go"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/Users/work/sdk/go1.16.14"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/work/sdk/go1.16.14/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.16.14"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/work/workspace/myapp/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/72/byjy11cs0dj_z3rjtxnj_nn00000gn/T/go-build1154361502=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

  1. repo mydomain.com/a/bnet has tag v1.23.13.
  2. repo mydomain.com/a/bnet download direct:GONOPROXY="*mydomain.com*"
  3. repo mydomain.com/myapp require mydomain.com/a/bnet@v1.23.13
  4. clean mod cache: go clean -modcache
  5. cd mydomain.com/myapp
  6. exec go version,output: go version go1.16.14 darwin/amd64
  7. exec go mod download has error:

go mod download: mydomain.com/a/bnet@v1.23.13: invalid version: resolves to version v1.23.15-0.20220221055748-c5a5cd77b294 (v1.23.13 is not a tag)

  1. with go1.16.13, exec go1.16.13 mod download ,there is no error, download success
  2. retry with go1.16.14 ,exec go1.16.14 mod download again, success

there was no useful error message, when exec go mod doanload -x

What did you expect to see?

What did you see instead?

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 38 (31 by maintainers)

Commits related to this issue

Most upvoted comments

Neato! Thinking about how to fix it — by any chance, do you have the log.decorate configuration option set in your global .gitconfig?

(We’re constantly running into issues from unanticipated formatting options leaked from user’s global configs. 😩)

yes, i have:

[log]
	decorate = full

v1.23.13, v1.23.14 is the same cimmit when v1.23.13 occurred this error, i create tag v1.23.14, v1.23.14 also occurred the same error

with go get has the some error.

go1.16.14 get -x mydomain.com/a/bnet@v1.23.13

# get https://mydomain.com/?go-get=1
# get https://mydomain.com/a/bnet?go-get=1
# get https://mydomain.com/a?go-get=1
# get https://mydomain.com/?go-get=1: Get "http://mydomain.com?go-get=1": redirected from secure URL https://mydomain.com/?go-get=1 to insecure URL http://mydomain.com?go-get=1
# get https://mydomain.com/a?go-get=1: Get "http://mydomain.com?go-get=1": redirected from secure URL https://mydomain.com/a?go-get=1 to insecure URL http://mydomain.com?go-get=1
# get https://mydomain.com/a/bnet?go-get=1: 200 OK (0.190s)
mkdir -p /Users/work/tmp/go_mod_cache/cache/vcs # git3 ssh://git@mydomain.com:8080/a/net
# lock /Users/work/tmp/go_mod_cache/cache/vcs/hashvalue0.lock# get https://mydomain.com/a?go-get=1: Get "http://mydomain.com?go-get=1": redirected from secure URL https://mydomain.com/a?go-get=1 to insecure URL http://mydomain.com?go-get=1
# /Users/work/tmp/go_mod_cache/cache/vcs/hashvalue0 for git3 ssh://git@mydomain.com:8080/a/bnet
cd /Users/work/tmp/go_mod_cache/cache/vcs/hashvalue0; git tag -l
0.015s # cd /Users/work/tmp/go_mod_cache/cache/vcs/hashvalue0; git tag -l
cd /Users/work/tmp/go_mod_cache/cache/vcs/hashvalue0; git -c log.showsignature=false log -n1 '--format=format:%H %ct %D' refs/tags/v1.23.13 --
0.018s # cd /Users/work/tmp/go_mod_cache/cache/vcs/hashvalue0; git -c log.showsignature=false log -n1 '--format=format:%H %ct %D' refs/tags/v1.23.13 --
cd /Users/work/tmp/go_mod_cache/cache/vcs/hashvalue0; git ls-remote -q origin
0.300s # cd /Users/work/tmp/go_mod_cache/cache/vcs/hashvalue0; git ls-remote -q origin
cd /Users/work/tmp/go_mod_cache/cache/vcs/hashvalue0; git -c log.showsignature=false log -n1 '--format=format:%H %ct %D' refs/tags/v1.23.15 --
0.014s # cd /Users/work/tmp/go_mod_cache/cache/vcs/hashvalue0; git -c log.showsignature=false log -n1 '--format=format:%H %ct %D' refs/tags/v1.23.15 --
cd /Users/work/tmp/go_mod_cache/cache/vcs/hashvalue0; git cat-file blob hashvalue3:go.mod
0.012s # cd /Users/work/tmp/go_mod_cache/cache/vcs/hashvalue0; git cat-file blob hashvalue3:go.mod
cd /Users/work/tmp/go_mod_cache/cache/vcs/hashvalue0; git -c log.showsignature=false log -n1 '--format=format:%H %ct %D' hashvalue1 --
0.010s # cd /Users/work/tmp/go_mod_cache/cache/vcs/hashvalue0; git -c log.showsignature=false log -n1 '--format=format:%H %ct %D' hashvalue1 --
cd /Users/work/tmp/go_mod_cache/cache/vcs/hashvalue0; git cat-file blob hashvalue1:go.mod
0.008s # cd /Users/work/tmp/go_mod_cache/cache/vcs/hashvalue0; git cat-file blob hashvalue1:go.mod
cd /Users/work/tmp/go_mod_cache/cache/vcs/hashvalue0; git for-each-ref --format %(refname) refs/tags --merged hashvalue1
0.008s # cd /Users/work/tmp/go_mod_cache/cache/vcs/hashvalue0; git for-each-ref --format %(refname) refs/tags --merged hashvalue1
cd /Users/work/tmp/go_mod_cache/cache/vcs/hashvalue0; git -c log.showsignature=false log -n1 '--format=format:%H %ct %D' hashvalue2 --
0.010s # cd /Users/work/tmp/go_mod_cache/cache/vcs/hashvalue0; git -c log.showsignature=false log -n1 '--format=format:%H %ct %D' hashvalue2 --
cd /Users/work/tmp/go_mod_cache/cache/vcs/hashvalue0; git cat-file blob hashvalue1:go.mod
0.008s # cd /Users/work/tmp/go_mod_cache/cache/vcs/hashvalue0; git cat-file blob hashvalue1:go.mod
go get: mydomain.com/a/bnet@v1.23.13: invalid version: resolves to version v1.23.15-0.20220221055748-hashvalue2 (v1.23.13 is not a tag)

the lastest version is v1.23.15

i found it @bcmills https://github.com/golang/go/blob/go1.16.14/src/cmd/go/internal/modfetch/codehost/git.go#L437-L469

git -c log.showsignature=false log -n1 '--format=format:%H %ct %D' c5a5cd77b294b44c5b1321d8d4c24fa5406dc5e7 --

withlog.decorate = full, Output:

c5a5cd77b294b44c5b1321d8d4c24fa5406dc5e7 1645423068 grafted, tag: refs/tags/v1.23.14, tag: refs/tags/v1.23.13

without log.decorate = full, output:

c5a5cd77b294b44c5b1321d8d4c24fa5406dc5e7 1645423068 grafted, tag: v1.23.14, tag: v1.23.13

but only support like this:

ede458df7cd0fdca520df19a33158086a8a68e81 1523994202 HEAD -> master, tag: v1.2.4-annotated, tag: v1.2.3, origin/master, origin/HEAD

go1.16.14 get -x mydomain.com/a/bnet@v1.23.13

Could you run go clean -modcache and then post go1.17,7 mod download -x mydomain.com/a/bnet@v1.23.13 specifically? go get does a lot of package-to-version resolution that makes it substantially more complicated to debug, and 1.17.7 is closer to the current code than 1.16.14 is (so it’s easier to narrow down the interactions with other changes).

Could you also check whether the issue reproduces with go1.18rc1?

git ,is Annotated Tags,i create is by:

git tag -a v1.23.13 -m ''
$ git show v1.23.13
tag v1.23.13
Tagger: xxx <xxx@yyy.com>
Date:   Mon Feb 21 14:12:35 2022 +0800


commit xyz (tag: refs/tags/v1.23.14, tag: refs/tags/v1.23.13)
$git version
git version 2.34.1