vitessio/vitess · error

Couldn't parse build timestamp %q: %v

Error message

Couldn't parse build timestamp %q: %v

What it means

parseBuildTime parses the build timestamp (from VCS stamping) with time.RFC3339. An unparseable BUILD_TIME override is only warned about, but an unparseable vcs time value is a build-injection bug — the value embedded at link time is malformed — so it panics at init.

Source

Thrown at go/vt/servenv/buildinfo.go:159

// parseBuildTime resolves the build timestamp into the pretty string and Unix
// timestamp used by AppVersion. An explicitly injected BUILD_TIME (via ldflags,
// in time.UnixDate format) takes precedence so that package/tarball builds can set
// it deliberately; otherwise it uses the VCS-stamped commit time (RFC3339), which
// the Go toolchain records for normal git builds. An unparseable override is logged
// and ignored so it falls through to the VCS time. It returns zero values when no
// usable timestamp is available.
func parseBuildTime(override, vcsTime string) (pretty string, unix int64) {
	if override != "" {
		t, err := time.Parse(time.UnixDate, override)
		if err == nil {
			return override, t.Unix()
		}
		log.Warn("Ignoring unparseable BUILD_TIME override", slog.String("build_time", override), slog.Any("error", err))
	}
	if vcsTime != "" {
		t, err := time.Parse(time.RFC3339, vcsTime)
		if err != nil {
			panic(fmt.Sprintf("Couldn't parse build timestamp %q: %v", vcsTime, err))
		}
		return vcsTime, t.Unix()
	}
	return "", 0
}

func init() {
	revision, revisionTime, modified := readVCSInfo()
	gitRev := resolveGitRev(revision, modified, buildGitRev)
	buildTimePretty, buildTime := parseBuildTime(buildTimeOverride, revisionTime)

	buildNumber, err := strconv.ParseInt(buildNumberStr, 10, 64)
	if err != nil {
		buildNumber = 0
	}

	AppVersion = versionInfo{
		buildHost:       buildHost,

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Fix the build script to emit RFC3339 format, e.g. date -u +'%Y-%m-%dT%H:%M:%SZ' or git log -1 --format=%cI
  2. Rebuild without the malformed timestamp override so the default (empty, 0) is used
  3. Test the exact string with `date -d` / a Go time.Parse(time.RFC3339, ...) before injecting

Example fix

// before
-BUILD_TIME=$(git log -1 --format=%cd --date=format:'%Y-%m-%d %H:%M:%S')
// after
BUILD_TIME=$(git log -1 --format=%cI)
Defensive patterns

Strategy: validation

Validate before calling

# validate before injecting in build scripts
[[ "$BUILD_TIME" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$ ]] || { echo "BUILD_TIME must be RFC3339"; exit 1; }

Prevention

When it happens

Trigger: Building/linking vitess with -ldflags that inject a vcs.buildTime / BUILD_TIME value not in RFC3339 format (e.g. '2024-01-02 15:04:05' instead of '2024-01-02T15:04:05Z'), causing panic at package init.

Common situations: Custom build scripts that format the git commit date incorrectly; overriding BUILD_TIME via ldflags with a locale-formatted date string; CI scripts using 'git log --format=%cd' with a custom date format.

Related errors


AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01). Data as JSON: /api/errors/8d2219a8421a01d7. Report an issue: GitHub.