{"record":{"id":"5bfac4ae713ba600","repo":"golang/go","slug":"cannot-parse-goauth-command-s-v","errorCode":null,"errorMessage":"cannot parse GOAUTH command %s: %v","messagePattern":"cannot parse GOAUTH command (.+?): (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/auth/userauth.go","lineNumber":110,"sourceCode":"\t}\n\treturn credentials, nil\n}\n\n// mapHeadersToPrefixes returns a mapping of prefix → http.Header without\n// the leading \"https://\".\nfunc mapHeadersToPrefixes(prefixes []string, header http.Header) map[string]http.Header {\n\tprefixToHeaders := make(map[string]http.Header, len(prefixes))\n\tfor _, p := range prefixes {\n\t\tp = strings.TrimPrefix(p, \"https://\")\n\t\tprefixToHeaders[p] = header.Clone() // Clone the header to avoid sharing\n\t}\n\treturn prefixToHeaders\n}\n\nfunc buildCommand(command string) (*exec.Cmd, error) {\n\twords, err := quoted.Split(command)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"cannot parse GOAUTH command %s: %v\", command, err)\n\t}\n\tcmd := exec.Command(words[0], words[1:]...)\n\treturn cmd, nil\n}\n\n// writeResponseToStdin writes the HTTP response to the command's stdin.\nfunc writeResponseToStdin(cmd *exec.Cmd, res *http.Response) error {\n\tvar output strings.Builder\n\toutput.WriteString(res.Proto + \" \" + res.Status + \"\\n\")\n\tfor k, v := range res.Header {\n\t\toutput.WriteString(k + \": \" + strings.Join(v, \", \") + \"\\n\")\n\t}\n\toutput.WriteString(\"\\n\")\n\tcmd.Stdin = strings.NewReader(output.String())\n\treturn nil\n}\n","sourceCodeStart":92,"sourceCodeEnd":127,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/auth/userauth.go#L92-L127","documentation":"Raised by buildCommand when quoted.Split(command) fails to parse the GOAUTH command string with Go's shell-like quoting rules. The %s is the offending command string, %v the quoted.Split error (typically an unclosed quote or invalid escape). This happens before any process is started.","triggerScenarios":"The GOAUTH environment variable contains a command string with unbalanced single or double quotes, or an invalid backslash escape that quoted.Split rejects.","commonSituations":"An unclosed quote such as `GOAUTH='my-auth \"cmd'`; a Windows path with an unquoted trailing backslash; mixed quote styles; a value built by string concatenation that drops a closing quote.","solutions":["Balance all quotes in the GOAUTH value.","Quote paths containing spaces with single quotes: `GOAUTH='/path with spaces/auth'`.","Inspect the resolved value: `go env GOAUTH`.","Avoid unnecessary nesting of quotes; prefer one quoting style."],"exampleFix":"// before\nGOAUTH='my-auth \"cmd'\n// after\nGOAUTH='my-auth \"cmd\"'","handlingStrategy":"validation","validationCode":"// Validate the GOAUTH command string parses before the go command reads it.\nif _, err := quoted.Split(os.Getenv(\"GOAUTH\")); err != nil {\n    return fmt.Errorf(\"GOAUTH has unbalanced quoting: %w\", err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Balance all quotes in the GOAUTH value.","Inspect the resolved value with `go env GOAUTH`.","Use a single consistent quoting style for paths with spaces."],"tags":["go-toolchain","goauth","authentication","quoting","config","env"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}