{"record":{"id":"a771e813e339c98f","repo":"golang/go","slug":"could-not-run-command-s-v-s","errorCode":null,"errorMessage":"could not run command %s: %v\n%s","messagePattern":"could not run command (.+?): (.+?)\n(.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/auth/userauth.go","lineNumber":35,"sourceCode":"// runAuthCommand executes a user provided GOAUTH command, parses its output, and\n// returns a mapping of prefix → http.Header.\n// It uses the client to verify the credential and passes the status to the\n// command's stdin.\n// res is used for the GOAUTH command's stdin.\nfunc runAuthCommand(command string, url string, res *http.Response) (map[string]http.Header, error) {\n\tif command == \"\" {\n\t\tpanic(\"GOAUTH invoked an empty authenticator command:\" + command) // This should be caught earlier.\n\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) {","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/auth/userauth.go#L17-L53","documentation":"Emitted from runAuthCommand in the branch `if res != nil && writeResponseToStdin(cmd, res) != nil`. This branch is effectively dead code in the current source: writeResponseToStdin (userauth.go:117-125) always returns nil, and the `err` referenced in the format string is the already-checked buildCommand error (guaranteed nil at this point). If a future refactor makes writeResponseToStdin return a real error, this message would print `<nil>` for %v. End users cannot trigger it today.","triggerScenarios":"Not reachable in the current codebase — writeResponseToStdin never returns a non-nil error, so the condition is always false.","commonSituations":"N/A; latent bug. Would only surface after a refactor that adds a failure mode to writeResponseToStdin without updating this branch.","solutions":["No end-user action; this is dead code today.","If maintaining: capture the real error from writeResponseToStdin and use it instead of the stale `err` variable."],"exampleFix":"// before\nif res != nil && writeResponseToStdin(cmd, res) != nil {\n    return nil, fmt.Errorf(\"could not run command %s: %v\\n%s\", command, err, cmd.Stderr)\n}\n// after\nif res != nil {\n    if werr := writeResponseToStdin(cmd, res); werr != nil {\n        return nil, fmt.Errorf(\"could not write response to command %s: %v\\n%s\", command, werr, cmd.Stderr)\n    }\n}","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Dead code in the current source; no user trigger.","If maintaining runAuthCommand, capture the real writeResponseToStdin error instead of the stale `err` variable."],"tags":["go-toolchain","goauth","authentication","dead-code","latent-bug"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}