{"record":{"id":"703da45d3451357f","repo":"golang/go","slug":"value-contains-space","errorCode":null,"errorMessage":"value contains space","messagePattern":"value contains space","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modload/init.go","lineNumber":2287,"sourceCode":"\ts := strings.FieldsFunc(path, f)\n\tif len(s) > 0 {\n\t\tm = s[0]\n\t}\n\n\tm = strings.TrimLeft(m, \"0\")\n\n\tif m == \"\" {\n\t\treturn url + \".v1\"\n\t}\n\treturn url + \".v\" + m\n}\n\nfunc CheckGodebug(verb, k, v string) error {\n\tif strings.ContainsAny(k, \" \\t\") {\n\t\treturn fmt.Errorf(\"key contains space\")\n\t}\n\tif strings.ContainsAny(v, \" \\t\") {\n\t\treturn fmt.Errorf(\"value contains space\")\n\t}\n\tif strings.ContainsAny(k, \",\") {\n\t\treturn fmt.Errorf(\"key contains comma\")\n\t}\n\tif strings.ContainsAny(v, \",\") {\n\t\treturn fmt.Errorf(\"value contains comma\")\n\t}\n\tif k == \"default\" {\n\t\tif !strings.HasPrefix(v, \"go\") || !gover.IsValid(v[len(\"go\"):]) {\n\t\t\treturn fmt.Errorf(\"value for default= must be goVERSION\")\n\t\t}\n\t\tif gover.Compare(v[len(\"go\"):], gover.Local()) > 0 {\n\t\t\treturn fmt.Errorf(\"default=%s too new (toolchain is go%s)\", v, gover.Local())\n\t\t}\n\t\treturn nil\n\t}\n\tif godebugs.Lookup(k) != nil {\n\t\treturn nil","sourceCodeStart":2269,"sourceCodeEnd":2305,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modload/init.go#L2269-L2305","documentation":"CheckGodebug rejected a godebug directive because the VALUE contains a space or tab. This is the second guard in the validator, after the key check. Same root cause class as 1078 but on the right-hand side of the '='.","triggerScenarios":"A godebug line like 'godebug key=value with space' or 'godebug key=\"a b\"' trips strings.ContainsAny(v, \" \\t\").","commonSituations":"Trying to embed a descriptive or multi-field value; copy-pasting a shell-quoted GODEBUG value that contained spaces; misunderstanding that godebug values are single tokens.","solutions":["Strip whitespace from the value: 'godebug key=0' style single-token values.","If multiple values are needed, that setting likely is not supported as multi-valued; check the GODEBUG docs.","Ensure no trailing spaces on the directive line.","Re-run to catch any remaining (comma / unknown key / default=) errors."],"exampleFix":"// before (go.work)\ngodebug http2tls=strict mode   // value has a space\n\n// after\ngodebug http2client=0          // a real single-token setting","handlingStrategy":"validation","validationCode":"// Validate godebug values for whitespace before commit.\nfunc validGodebugValue(v string) error {\n    if strings.ContainsAny(v, \" \\t\") {\n        return errors.New(\"godebug value contains whitespace\")\n    }\n    return nil\n}","typeGuard":"func isGodebugValueWellFormed(v string) bool {\n    return !strings.ContainsAny(v, \" \\t,\")\n}","tryCatchPattern":"out, err := exec.Command(\"go\", \"build\", \"./...\").CombinedOutput()\nif err != nil && bytes.Contains(out, []byte(\"value contains space\")) {\n    return fmt.Errorf(\"godebug value has whitespace; fix directive: %s\", out)\n}\nreturn err","preventionTips":["Use single-token values; strip trailing spaces.","One key=value per godebug directive; never multi-field values.","Add godebug lines via the edit subcommands.","Lint godebug directives in pre-commit."],"tags":["godebug","validation","whitespace","go-mod","go-work"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}