{"record":{"id":"32b7a503efe81c32","repo":"golang/go","slug":"missing-gosumdb","errorCode":null,"errorMessage":"missing GOSUMDB","messagePattern":"missing GOSUMDB","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modfetch/sumdb.go","lineNumber":114,"sourceCode":"\t// for sum.golang.org. If there are more\n\t// of these we should add a map like knownGOSUMDB.\n\tgosumdb := cfg.GOSUMDB\n\tif gosumdb == \"sum.golang.google.cn\" {\n\t\tgosumdb = \"sum.golang.org https://sum.golang.google.cn\"\n\t}\n\n\tif gosumdb == \"off\" {\n\t\treturn \"\", nil, fmt.Errorf(\"checksum database disabled by GOSUMDB=off\")\n\t}\n\n\tkey := strings.Fields(gosumdb)\n\tif len(key) >= 1 {\n\t\tif k := knownGOSUMDB[key[0]]; k != \"\" {\n\t\t\tkey[0] = k\n\t\t}\n\t}\n\tif len(key) == 0 {\n\t\treturn \"\", nil, fmt.Errorf(\"missing GOSUMDB\")\n\t}\n\tif len(key) > 2 {\n\t\treturn \"\", nil, fmt.Errorf(\"invalid GOSUMDB: too many fields\")\n\t}\n\tvkey, err := note.NewVerifier(key[0])\n\tif err != nil {\n\t\treturn \"\", nil, fmt.Errorf(\"invalid GOSUMDB: %v\", err)\n\t}\n\tname := vkey.Name()\n\n\t// No funny business in the database name.\n\tdirect, err := url.Parse(\"https://\" + name)\n\tif err != nil || strings.HasSuffix(name, \"/\") || *direct != (url.URL{Scheme: \"https\", Host: direct.Host, Path: direct.Path, RawPath: direct.RawPath}) || direct.RawPath != \"\" || direct.Host == \"\" {\n\t\treturn \"\", nil, fmt.Errorf(\"invalid sumdb name (must be host[/path]): %s %+v\", name, *direct)\n\t}\n\n\t// Determine how to get to database.\n\tvar base *url.URL","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modfetch/sumdb.go#L96-L132","documentation":"This error occurs when the GOSUMDB environment variable, after whitespace splitting and known-name lookup, yields zero fields. GOSUMDB should contain at minimum a checksum database name or verifier key. An empty string or a string containing only whitespace after the knownGOSUMDB alias resolution triggers this.","triggerScenarios":"GOSUMDB is set to an empty string or whitespace-only value. The string is split with strings.Fields (which handles multiple spaces), and if no tokens remain, the error fires. This can happen if GOSUMDB is explicitly set to '' or a script sets it to a variable that expands to nothing.","commonSituations":"A script sets GOSUMDB=\"\" (empty string) explicitly, or assigns it from an undefined variable. A Docker build sets ENV GOSUMDB= with no value. A CI pipeline conditionally sets GOSUMDB and the condition evaluates to empty.","solutions":["Unset the variable to use the default: 'go env -u GOSUMDB' (the default is sum.golang.org).","Set GOSUMDB to a valid value: 'go env -w GOSUMDB=sum.golang.org'.","Check the origin: 'go env GOSUMDB' and trace where the empty value comes from (shell profile, Dockerfile ENV, CI variable).","If using a custom checksum database, provide at least the name: 'go env -w GOSUMDB=your-sumdb-name' or a full key."],"exampleFix":"# before\n$ export GOSUMDB=\"\"\n$ go get example.com/mymodule\n# missing GOSUMDB\n\n# after\n$ go env -u GOSUMDB   # reset to default (sum.golang.org)\n$ go get example.com/mymodule","handlingStrategy":"validation","validationCode":"// Validate GOSUMDB is non-empty\nfunc validateGOSUMDBNotEmpty() error {\n    out, err := exec.Command(\"go\", \"env\", \"GOSUMDB\").Output()\n    if err != nil { return err }\n    val := strings.TrimSpace(string(out))\n    if val == \"\" {\n        return fmt.Errorf(\"GOSUMDB is empty; run: go env -u GOSUMDB\")\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if strings.Contains(stderr, \"missing GOSUMDB\") {\n    // GOSUMDB is unset or whitespace-only\n    // Auto-fix: exec.Command(\"go\", \"env\", \"-u\", \"GOSUMDB\")\n}","preventionTips":["Never set GOSUMDB to an empty string explicitly","Audit environment variables in Dockerfiles and CI configs for empty values","Use 'go env -u' to unset rather than setting to empty"],"tags":["go-sumdb","gosumdb","configuration","env-var","checksum"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}