{"record":{"id":"9d755d7b9bcdf63e","repo":"projectdiscovery/nuclei","slug":"failed-to-read-method-line-s","errorCode":null,"errorMessage":"failed to read method line: %s","messagePattern":"failed to read method line: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/input/types/http.go","lineNumber":230,"sourceCode":"\n// Clone clones the response\nfunc (hr *HttpResponse) Clone() *HttpResponse {\n\treturn &HttpResponse{\n\t\tStatusCode: hr.StatusCode,\n\t\tHeaders:    hr.Headers.Clone(),\n\t\tBody:       hr.Body,\n\t\tRaw:        hr.Raw,\n\t}\n}\n\n// ParseRawRequest parses a raw request from a string\n// and returns the request and response object\n// Note: it currently does not parse response and is meant to be added manually since its a optional field\nfunc ParseRawRequest(raw string) (rr *RequestResponse, err error) {\n\tprotoReader := textproto.NewReader(bufio.NewReader(strings.NewReader(raw)))\n\tmethodLine, err := protoReader.ReadLine()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to read method line: %s\", err)\n\t}\n\trr = &RequestResponse{\n\t\tRequest: &HttpRequest{},\n\t}\n\t/// must contain at least 3 parts\n\tparts := strings.Split(methodLine, \" \")\n\tif len(parts) < 3 {\n\t\treturn nil, fmt.Errorf(\"invalid method line: %s\", methodLine)\n\t}\n\tmethod := parts[0]\n\trr.Request.Method = method\n\n\t// the request target is normally an origin-form path, but proxy captures and\n\t// .http files use the absolute form, which already carries the authority\n\tvar urlx *urlutil.URL\n\ttarget := parts[1]\n\tif stringsutil.HasPrefixAnyI(target, urlutil.HTTP+urlutil.SchemeSeparator, urlutil.HTTPS+urlutil.SchemeSeparator) {\n\t\t// urlutil.ParseAbsoluteURL only accepts lowercase schemes; preserve the","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/projectdiscovery/nuclei/blob/265b3a3dec374741614e342f813c10f8b38d2bb7/pkg/input/types/http.go#L212-L248","documentation":"ParseRawRequest could not read the first line of the raw request via net/textproto: the input was empty, whitespace-only, or the reader hit an error/EOF before any line. Every raw HTTP request must start with a method line like 'GET /path HTTP/1.1'.","triggerScenarios":"Calling ParseRawRequest with an empty string, a string of blank lines, or a document whose first line is missing (e.g. starting directly with 'Host: ...').","commonSituations":"Templates with raw requests where the YAML block scalar is empty; trailing/leading newlines making the first ReadLine blank is tolerated only if a line exists — fully empty input is not; copy-paste losing the first line.","solutions":["Ensure the raw string begins with a method line: 'GET / HTTP/1.1'","Trim leading whitespace/newlines before parsing if the source tends to inject them","Check the template's raw block indentation in YAML (block scalar content must be indented consistently)"],"exampleFix":"# before\nraw: |\n  Host: example.com\n\n# after\nraw: |\n  GET / HTTP/1.1\n  Host: example.com","handlingStrategy":"validation","validationCode":"func hasMethodLine(raw string) bool {\n    trimmed := strings.TrimLeft(raw, \" \\t\\r\\n\")\n    return trimmed != \"\" && !strings.HasPrefix(trimmed, \"\\n\")\n}\n\nif !hasMethodLine(raw) { /* reject/repair input before ParseRawRequest */ }","typeGuard":null,"tryCatchPattern":"On 'failed to read method line', treat the input as empty/garbage and skip the entry; do not retry with the same bytes.","preventionTips":["Always start raw blocks with the method line","Trim leading newlines when ingesting raw requests from external sources","Add a template lint step (nuclei -validate) before scans"],"tags":["input","raw-http","parsing","template"],"backgroundTag":null,"analyzedSha":"265b3a3dec374741614e342f813c10f8b38d2bb7","analyzedAt":"2026-08-15T20:05:51.855Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}