{"record":{"id":"1db520ca7b9fa2b2","repo":"ffuf/ffuf","slug":"could-not-read-request-s","errorCode":null,"errorMessage":"could not read request: %s","messagePattern":"could not read request: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/ffuf/optionsparser.go","lineNumber":742,"sourceCode":"\toptsCopy.HTTP.Postflights = clonePreflights(parseOpts.HTTP.Postflights)\n\tconf.Options = &optsCopy\n\treturn &conf, errs.ErrorOrNil()\n}\n\nfunc parseRawRequest(parseOpts *ConfigOptions, conf *Config) error {\n\tconf.RequestFile = parseOpts.Input.Request\n\tconf.RequestProto = parseOpts.Input.RequestProto\n\tfile, err := os.Open(parseOpts.Input.Request)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not open request file: %s\", err)\n\t}\n\tdefer file.Close()\n\n\tr := bufio.NewReader(file)\n\n\ts, err := r.ReadString('\\n')\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not read request: %s\", err)\n\t}\n\tparts := strings.Split(s, \" \")\n\tif len(parts) < 3 {\n\t\treturn fmt.Errorf(\"malformed request supplied\")\n\t}\n\t// Set the request Method\n\tconf.Method = parts[0]\n\n\tfor {\n\t\tline, err := r.ReadString('\\n')\n\t\tline = strings.TrimSpace(line)\n\n\t\tif err != nil || line == \"\" {\n\t\t\tbreak\n\t\t}\n\n\t\tp := strings.SplitN(line, \":\", 2)\n\t\tif len(p) != 2 {","sourceCodeStart":724,"sourceCodeEnd":760,"githubUrl":"https://github.com/ffuf/ffuf/blob/33c67d28c85b94589d029b3bcaff205a40cee9c4/pkg/ffuf/optionsparser.go#L724-L760","documentation":"After opening the raw request file, parseRawRequest reads the first line (the request line) with bufio.Reader.ReadString. Any read error — including EOF from a zero-byte or truncated file — is wrapped in this message and returned, since a request cannot be reconstructed without the method/URL line.","triggerScenarios":"ConfigFromOptions -> parseRawRequest when the file opens but the first ReadString('\\n') fails: an empty request file, a file whose first line has no trailing newline and hits EOF, a device/special file, or I/O errors on a broken mount.","commonSituations":"Saving an empty or truncated file from a proxy export; piping/copying a request that lost its content; capturing only headers without a request line; network filesystem issues making the file unreadable mid-read.","solutions":["Ensure the file starts with a valid request line like 'GET /path HTTP/1.1' with a newline","Re-export the request from the proxy (Burp/ZAP 'Copy as request file')","Check the file is non-empty: wc -c <file>","Read the file directly to confirm its first line is intact"],"exampleFix":"// before (empty or truncated req.txt)\n(empty file)\n// after (req.txt)\nGET /dir/FUZZ HTTP/1.1\nHost: example.com\n\n","handlingStrategy":"try-catch","validationCode":"f, err := os.Open(opts.Input.Request)\nif err != nil {\n    return err\n}\nfirst, err := bufio.NewReader(f).ReadString('\\n')\nf.Close()\nif err != nil || strings.TrimSpace(first) == \"\" {\n    return errors.New(\"request file is empty or missing a request line\")\n}","typeGuard":null,"tryCatchPattern":"err := ffuf.ConfigFromOptions(parseOpts)\nif err != nil {\n    if strings.Contains(err.Error(), \"could not read request\") {\n        log.Fatalf(\"request file unreadable/empty: %v — re-export the raw request\", err)\n    }\n    return err\n}","preventionTips":["Verify the first line of the request file is a full request line","Re-export raw requests from the proxy rather than hand-writing them","Check file size is non-zero before use"],"tags":["file-io","http","request-file"],"backgroundTag":"malformed-request-file","analyzedSha":"33c67d28c85b94589d029b3bcaff205a40cee9c4","analyzedAt":"2026-09-04T18:24:34.068Z","contentChangedAt":"2026-09-04T18:24:34.068Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}