{"record":{"id":"5144b9434608781c","repo":"golang/go","slug":"cannot-parse-output-of-goauth-command-s-v","errorCode":null,"errorMessage":"cannot parse output of GOAUTH command %s: %v","messagePattern":"cannot parse output of GOAUTH command (.+?): (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/auth/userauth.go","lineNumber":43,"sourceCode":"\t}\n\tcmd, err := buildCommand(command)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif url != \"\" {\n\t\tcmd.Args = append(cmd.Args, url)\n\t}\n\tcmd.Stderr = new(strings.Builder)\n\tif res != nil && writeResponseToStdin(cmd, res) != nil {\n\t\treturn nil, fmt.Errorf(\"could not run command %s: %v\\n%s\", command, err, cmd.Stderr)\n\t}\n\tout, err := cmd.Output()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not run command %s: %v\\n%s\", command, err, cmd.Stderr)\n\t}\n\tcredentials, err := parseUserAuth(string(out))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"cannot parse output of GOAUTH command %s: %v\", command, err)\n\t}\n\treturn credentials, nil\n}\n\n// parseUserAuth parses the output from a GOAUTH command and\n// returns a mapping of prefix → http.Header without the leading \"https://\"\n// or an error if the data does not follow the expected format.\n// Returns a nil error and an empty map if the data is empty.\n// See the expected format in 'go help goauth'.\nfunc parseUserAuth(data string) (map[string]http.Header, error) {\n\tcredentials := make(map[string]http.Header)\n\tfor data != \"\" {\n\t\tvar line string\n\t\tvar ok bool\n\t\tvar urls []string\n\t\t// Parse URLS first.\n\t\tfor {\n\t\t\tline, data, ok = strings.Cut(data, \"\\n\")","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/auth/userauth.go#L25-L61","documentation":"Emitted from runAuthCommand when the custom GOAUTH command ran successfully (exit 0) but parseUserAuth rejected its stdout. parseUserAuth expects a repeating structure of: one or more absolute URL lines, a blank line, one or more `Name: value` header lines, a blank line (see `go help goauth`). Empty output is allowed and yields no credentials.","triggerScenarios":"The command prints non-empty output that does not follow the URLs-blank-headers-blank format: an unparseable URL, a header line missing `: `, a missing terminating blank line, or a totally different shape (JSON, free text).","commonSituations":"Command prints a login banner, debug text, or JSON to stdout instead of the documented format; CRLF line endings; missing trailing blank line; header without a space after the colon.","solutions":["Read `go help goauth` and emit exactly: URL line(s), blank line, `Name: value` header line(s), blank line.","Send any diagnostic/log output to stderr, not stdout.","Use LF (\\n) line endings, not CRLF.","Return empty output (no credentials) rather than malformed text when there is nothing to provide."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Lint GOAUTH command output against the documented format before use.\nfunc validateAuthOutput(s string) error {\n    _, err := parseUserAuth(s) // reuse the parser in a test\n    return err\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Emit the exact format from `go help goauth`: URLs, blank line, `Name: value` headers, blank line.","Send diagnostics to stderr, never stdout.","Use LF line endings.","Return empty output (not malformed text) when there are no credentials."],"tags":["go-toolchain","goauth","authentication","parsing","custom-command","format"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}