{"record":{"id":"30c9f97d321c0507","repo":"tsenart/vegeta","slug":"bad-header-s","errorCode":null,"errorMessage":"bad header: %s","messagePattern":"bad header: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/targets.go","lineNumber":320,"sourceCode":"\t\ttgt.URL = tokens[1]\n\t\tline = strings.TrimSpace(sc.Peek())\n\t\tif line == \"\" || startsWithHTTPMethod(line) {\n\t\t\treturn nil\n\t\t}\n\t\tfor sc.Scan() {\n\t\t\tif line = strings.TrimSpace(sc.Text()); line == \"\" {\n\t\t\t\tbreak\n\t\t\t} else if strings.HasPrefix(line, \"#\") {\n\t\t\t\tcontinue\n\t\t\t} else if strings.HasPrefix(line, \"@\") {\n\t\t\t\tif tgt.Body, err = os.ReadFile(line[1:]); err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"bad body: %w\", err)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\ttokens = strings.SplitN(line, \":\", 2)\n\t\t\tif len(tokens) < 2 {\n\t\t\t\treturn fmt.Errorf(\"bad header: %s\", line)\n\t\t\t}\n\t\t\tfor i := range tokens {\n\t\t\t\tif tokens[i] = strings.TrimSpace(tokens[i]); tokens[i] == \"\" {\n\t\t\t\t\treturn fmt.Errorf(\"bad header: %s\", line)\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Add key/value directly to the http.Header (map[string][]string).\n\t\t\t// http.Header.Add() canonicalizes keys but vegeta is used\n\t\t\t// to test systems that require case-sensitive headers.\n\t\t\ttgt.Header[tokens[0]] = append(tgt.Header[tokens[0]], tokens[1])\n\t\t}\n\t\tif err = sc.Err(); err != nil {\n\t\t\treturn ErrNoTargets\n\t\t}\n\t\treturn nil\n\t}\n}\n","sourceCodeStart":302,"sourceCodeEnd":338,"githubUrl":"https://github.com/tsenart/vegeta/blob/cf5811269046c672a604b1eb352204d30f16ae4a/lib/targets.go#L302-L338","documentation":"Returned when a header line in the targets file has no ':' separator, so it cannot be split into key/value. The parser requires header lines of the form \"Key: Value\".","triggerScenarios":"A continuation line in a targets block that lacks a colon, e.g. \"Authorization\" alone, or a value that accidentally wrapped onto its own line without \"Key:\".","commonSituations":"Copy-pasted headers losing the colon, curl -H style flags pasted verbatim (\"-H 'X: Y'\"), or JSON-ish lines mistakenly included in the target block.","solutions":["Format every header line as \"Key: Value\" with a colon separating them.","Remove stray lines (or prefix with '#') that are not method/URL, header, body '@' line, or blank.","Check the offending line text in the error and add the missing colon.","Avoid pasting curl command syntax directly into targets files."],"exampleFix":"// before\nGET http://api/\nAuthorization Bearer xyz\n// after\nGET http://api/\nAuthorization: Bearer xyz","handlingStrategy":"validation","validationCode":"func validHeaderLine(line string) bool {\n    return strings.Contains(line, \":\") &&\n        strings.TrimSpace(strings.SplitN(line, \":\", 2)[0]) != \"\"\n}","typeGuard":null,"tryCatchPattern":"if _, err := vegeta.NewTargets(r); err != nil {\n    if strings.Contains(err.Error(), \"bad header:\") {\n        return fmt.Errorf(\"header lines need 'Key: Value' form: %w\", err)\n    }\n    return err\n}","preventionTips":["Format header lines strictly as 'Key: Value'.","Strip curl-style '-H' flags before pasting into targets files.","Lint targets files for lines missing ':' after the first request line."],"tags":["go","targets","http-headers"],"backgroundTag":"invalid-header-format","analyzedSha":"cf5811269046c672a604b1eb352204d30f16ae4a","analyzedAt":"2026-08-31T11:04:20.464Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}