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: improve "invalid pseudo-version: does not match version-control timestamp" error message UX #36974

Closed
wadells opened this issue Feb 2, 2020 · 4 comments
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@wadells
Copy link
Contributor

wadells commented Feb 2, 2020

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

$ go version
go version devel +866920a073 Sat Feb 1 06:01:05 2020 +0000 darwin/amd64

Does this issue reproduce with the latest release?

Yes, I found this in 1.13.5, and devel +866920a073 is current as of a clone on 2020-02-01.

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/walt/Library/Caches/go-build"
GOENV="/Users/walt/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/walt/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/walt/git/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/walt/git/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/walt/git/go/src/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 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/7y/j07kyx452vs7y90kkt0x27lm0000gn/T/go-build080166988=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I encountered a go mod tidy error in the wild (the cause of the error is irrelevant & fixed, the error message is what I want to focus on):

Full Repro
$ git clone https://github.com/gravitational/robotest
Cloning into 'robotest'...
remote: Enumerating objects: 171, done.
remote: Counting objects: 100% (171/171), done.
remote: Compressing objects: 100% (109/109), done.
remote: Total 4982 (delta 95), reused 103 (delta 58), pack-reused 4811
Receiving objects: 100% (4982/4982), 1.02 MiB | 9.70 MiB/s, done.
Resolving deltas: 100% (3114/3114), done.
$ cd robotest
$ git checkout ced833702831
Note: checking out 'ced833702831'.
# snip 'detached HEAD' message
$ go mod tidy
go: github.com/gravitational/trace@v0.0.0-20190626162700-a535a178675f: invalid pseudo-version: does not match version-control timestamp (2019-07-26T14:27:06Z)

What did you expect to see?

It would be nice if the error message date format matched the go.mod/go.sum date format. This would allow for cut-and-paste-ability to fix the error. Essentially, I believe the following two lines should use the same date format:

segment := fmt.Sprintf("%s-%s", t.UTC().Format("20060102150405"), rev)

return fmt.Errorf("does not match version-control timestamp (%s)", info.Time.UTC().Format(time.RFC3339))

What did you see instead?

I saw 2019-07-26T14:27:06Z in the error message and did not realize that this datestamp was directly relatable to the corrupted 20190626162700 datestamp in the pseudo version. I probably sank an hour or two tracking down the above lines and reinventing the following wheel:

TZ=UTC git show --date=format-local:%Y%m%d%k%M%S --format=%cd <SHA>

Before I facepalmed and realized that the timestamp I wanted was in the error message all along, just formatted differently than what go.mod expected.

@wadells
Copy link
Contributor Author

wadells commented Feb 2, 2020

To be fair, the truncate pseudo-version & go mod tidy solution discussed here could have solved my problem quickly:

https://golang.org/doc/go1.13#version-validation

I'd just never seen it before.

@wadells
Copy link
Contributor Author

wadells commented Feb 2, 2020

If we get to the point where we decide there is something to change here, I'd like to try contributing the fix please. I've got a patch ready for how I think it could be improved, but I wanted to file this issue first for discussion, to avoid "lack of a linked GitHub issue" mentioned at https://golang.org/doc/contribute.html#mistakes.

@wadells
Copy link
Contributor Author

wadells commented Feb 2, 2020

@bcmills you look like the subject matter expert for pseudo-version validation & error messages. Your input would be appreciated.

@gopherbot
Copy link

Change https://golang.org/cl/217437 mentions this issue: cmd/go: improve pseudo-version timestamp error

@bcmills bcmills changed the title Improve "invalid pseudo-version: does not match version-control timestamp" error message UX cmd/go: improve "invalid pseudo-version: does not match version-control timestamp" error message UX Feb 3, 2020
@bcmills bcmills added modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Feb 3, 2020
@bcmills bcmills added this to the Go1.15 milestone Feb 3, 2020
@golang golang locked and limited conversation to collaborators Mar 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants