{"record":{"id":"171f7bbf66690360","repo":"vitessio/vitess","slug":"golang-version-malformatted-s","errorCode":null,"errorMessage":"golang version malformatted: %s","messagePattern":"golang version malformatted: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/tools/go-upgrade/go-upgrade.go","lineNumber":337,"sourceCode":"\n\tbody, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar latestGoReleases []latestGolangRelease\n\terr = json.Unmarshal(body, &latestGoReleases)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar versions version.Collection\n\tfor _, release := range latestGoReleases {\n\t\tif !release.Stable {\n\t\t\tcontinue\n\t\t}\n\t\tif !strings.HasPrefix(release.Version, \"go\") {\n\t\t\treturn nil, fmt.Errorf(\"golang version malformatted: %s\", release.Version)\n\t\t}\n\t\tnewVersion, err := version.NewVersion(release.Version[2:])\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tversions = append(versions, newVersion)\n\t}\n\treturn versions, nil\n}\n\n// chooseNewVersion decides what will be the next version we're going to use in our codebase.\n// Given the current Golang version, the available latest versions and whether we allow major upgrade or not,\n// chooseNewVersion will return either the new version or nil if we cannot/don't need to upgrade.\nfunc chooseNewVersion(curVersion *version.Version, latestVersions version.Collection, allowMajorUpgrade bool) *version.Version {\n\tselectedVersion := curVersion\n\tfor _, latestVersion := range latestVersions {\n\t\tif !allowMajorUpgrade && !isSameMajorMinorVersion(latestVersion, selectedVersion) {\n\t\t\tcontinue","sourceCodeStart":319,"sourceCodeEnd":355,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/tools/go-upgrade/go-upgrade.go#L319-L355","documentation":"getLatestStableGolangReleases fetches Go release metadata (from the Go.dev releases API) and parses each stable release's version string, which should start with the prefix \"go\" (e.g. go1.22.5). If a stable release version string lacks that prefix, the tool treats it as malformed and aborts with this error.","triggerScenarios":"The releases API response contains a stable release whose Version field doesn't start with \"go\" — typically due to an API response format change or unexpected entry.","commonSituations":"Upstream Go.dev API schema change; a proxy/mirror returning altered release metadata; network middleware rewriting the response; running with a cached or mocked fixture that has non-\"go\"-prefixed versions.","solutions":["Inspect the raw releases API response (https://go.dev/dl/?mode=json) for entries whose version lacks the 'go' prefix","If the API format changed, update getLatestStableGolangReleases to parse the new format","Check for proxies/HTTP overrides altering the response and bypass them","Retry later if it's a transient upstream data issue"],"exampleFix":"// before\nif !strings.HasPrefix(release.Version, \"go\") {\n    return nil, fmt.Errorf(\"golang version malformatted: %s\", release.Version)\n}\n// after\nif !strings.HasPrefix(release.Version, \"go\") {\n    log.Warn(\"skipping unexpected release version\", slog.Any(\"version\", release.Version))\n    continue\n}","handlingStrategy":"fallback","validationCode":"for _, r := range releases {\n    if r.Stable && !strings.HasPrefix(r.Version, \"go\") {\n        log.Warn(\"unexpected release entry, skipping\", slog.Any(\"version\", r.Version))\n    }\n}","typeGuard":"func isWellFormedGoRelease(v string) bool {\n    return strings.HasPrefix(v, \"go\") && len(v) > 2\n}","tryCatchPattern":"releases, err := getLatestStableGolangReleases()\nif err != nil {\n    return fmt.Errorf(\"go.dev releases API returned unexpected data; retry or fall back to current version: %w\", err)\n}","preventionTips":["Pin or validate the releases API endpoint and check for schema changes upstream","Skip-and-log unexpected entries instead of failing the whole upgrade run","Test the parser against a saved API fixture whenever go.dev changes its response"],"tags":["golang","api","versioning","network"],"backgroundTag":"unexpected-api-response-format","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}