{"record":{"id":"332215b2271f413f","repo":"golang/go","slug":"value-contains-comma","errorCode":null,"errorMessage":"value contains comma","messagePattern":"value contains comma","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modload/init.go","lineNumber":2293,"sourceCode":"\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\n\t}\n\tfor _, info := range godebugs.Removed {\n\t\tif info.Name == k {\n\t\t\tif info.Old(v) {\n\t\t\t\treturn fmt.Errorf(\"removed GODEBUG %q set to old value %q (https://go.dev/doc/godebug#go-1%v)\", k, v, info.Removed)\n\t\t\t}","sourceCodeStart":2275,"sourceCodeEnd":2311,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modload/init.go#L2275-L2311","documentation":"Thrown by CheckGodebug when a GODEBUG value (the part after '=') contains a comma. Since the go.mod/go.work godebug directive format uses commas only as separators between multiple key=value pairs on the same conceptual list, a value with a comma would be misinterpreted as delimiting a new entry. This is checked after the key-space and value-space checks but before the 'default=' special-case.","triggerScenarios":"A godebug directive in go.mod or go.work has a value like 'godebug somekey=1,2' where the value portion after '=' contains a comma. The check strings.ContainsAny(v, \",\") returns true.","commonSituations":"Attempting to pass a multi-valued setting (e.g. a list) into a single GODEBUG value. Confusing the environment variable GODEBUG syntax (comma-separated) with the go.mod directive syntax (one per line).","solutions":["Locate the godebug line in go.mod/go.work whose value contains a comma.","Determine whether the comma was intended as a list separator — if so, use separate godebug lines for each setting instead.","If the value genuinely needs a comma, verify the GODEBUG setting name is valid and check its documented value format at https://go.dev/doc/godebug."],"exampleFix":"// before (go.mod)\ngodebug asn1tag=0,1\n\n// after\ngodebug asn1tag=0\ngodebug otherflag=1","handlingStrategy":"validation","validationCode":"// Validate a godebug value before writing it to go.mod/go.work.\nfunc validateGodebugValue(v string) error {\n    if strings.ContainsAny(v, \" \\t\") {\n        return fmt.Errorf(\"value contains space\")\n    }\n    if strings.ContainsAny(v, \",\") {\n        return fmt.Errorf(\"value contains comma\")\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["GODEBUG values are single tokens (e.g. 0, 1, a named value) — never comma-separated lists.","Remember the godebug directive differs from the GODEBUG env var: the env var uses commas between settings; the directive uses one line per setting.","Use 'go mod edit -godebug=' to add settings safely."],"tags":["godebug","go-mod","go-work","validation","config-syntax"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}