{"record":{"id":"97f835eeaa523f68","repo":"golang/go","slug":"could-not-parse-url-s-v","errorCode":null,"errorMessage":"could not parse URL %s: %v","messagePattern":"could not parse URL (.+?): (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/auth/userauth.go","lineNumber":70,"sourceCode":"// 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\")\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"invalid format: missing empty line after URLs\")\n\t\t\t}\n\t\t\tif line == \"\" {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tu, err := url.ParseRequestURI(line)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"could not parse URL %s: %v\", line, err)\n\t\t\t}\n\t\t\turls = append(urls, u.String())\n\t\t}\n\t\t// Parse Headers second.\n\t\theader := make(http.Header)\n\t\tfor {\n\t\t\tline, data, ok = strings.Cut(data, \"\\n\")\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"invalid format: missing empty line after headers\")\n\t\t\t}\n\t\t\tif line == \"\" {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tname, value, ok := strings.Cut(line, \": \")\n\t\t\tvalue = strings.TrimSpace(value)\n\t\t\tif !ok || !validHeaderFieldName(name) || !validHeaderFieldValue(value) {\n\t\t\t\treturn nil, fmt.Errorf(\"invalid format: invalid header line\")\n\t\t\t}","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/auth/userauth.go#L52-L88","documentation":"Raised inside parseUserAuth for each non-blank URL line: the line must pass url.ParseRequestURI, which requires an absolute URI with a scheme. If parsing fails, this error names the offending line and wraps the parse error.","triggerScenarios":"A URL line that is not an absolute request URI: a bare hostname (`example.com`), a path without scheme (`/foo`), a line containing spaces or control characters, or invalid percent-encoding.","commonSituations":"Writing `example.com` instead of `https://example.com`; trailing whitespace or a carriage return; non-ASCII characters; unencoded spaces in the path.","solutions":["Always include the scheme and host: `https://example.com/path`.","Trim trailing whitespace/CR from each URL line.","Percent-encode any spaces or non-ASCII bytes in the path/query.","Test lines with Go's `url.ParseRequestURI` before emitting them."],"exampleFix":"// before\nexample.com\n// after\nhttps://example.com\n","handlingStrategy":"validation","validationCode":"// Validate each URL line before emitting it.\nif _, err := url.ParseRequestURI(line); err != nil {\n    return fmt.Errorf(\"invalid URL line %q: %w\", line, err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include scheme and host: `https://example.com/path`.","Trim trailing whitespace/CR.","Percent-encode spaces and non-ASCII bytes in the path/query."],"tags":["go-toolchain","goauth","authentication","parsing","url","custom-command"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:17:08.281Z"}