{"record":{"id":"0daa9871670bedaa","repo":"projectdiscovery/subfinder","slug":"response-size-read-cannot-be-negative","errorCode":null,"errorMessage":"response-size-read cannot be negative","messagePattern":"response-size-read cannot be negative","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/runner/validate.go","lineNumber":50,"sourceCode":"\t\treturn errors.New(\"threads cannot be zero\")\n\t}\n\tif options.Timeout == 0 {\n\t\treturn errors.New(\"timeout cannot be zero\")\n\t}\n\n\t// Always remove wildcard with hostip\n\tif options.HostIP && !options.RemoveWildcard {\n\t\treturn errors.New(\"hostip flag must be used with RemoveWildcard option\")\n\t}\n\n\t// The per-source results limit cannot be negative.\n\tif options.MaxResults < 0 {\n\t\treturn fmt.Errorf(\"max-results cannot be negative\")\n\t}\n\n\t// The response body size limit cannot be negative.\n\tif options.MaxResponseBodySize < 0 {\n\t\treturn fmt.Errorf(\"response-size-read cannot be negative\")\n\t}\n\n\tif options.Match != nil {\n\t\toptions.matchRegexes = make([]*regexp.Regexp, len(options.Match))\n\t\tvar err error\n\t\tfor i, re := range options.Match {\n\t\t\tif options.matchRegexes[i], err = regexp.Compile(stripRegexString(re)); err != nil {\n\t\t\t\treturn errors.New(\"invalid value for match regex option\")\n\t\t\t}\n\t\t}\n\t}\n\tif options.Filter != nil {\n\t\toptions.filterRegexes = make([]*regexp.Regexp, len(options.Filter))\n\t\tvar err error\n\t\tfor i, re := range options.Filter {\n\t\t\tif options.filterRegexes[i], err = regexp.Compile(stripRegexString(re)); err != nil {\n\t\t\t\treturn errors.New(\"invalid value for filter regex option\")\n\t\t\t}","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/projectdiscovery/subfinder/blob/7a0b91f0fac01b62c65328bd771a3560ae611d6a/pkg/runner/validate.go#L32-L68","documentation":"validateOptions enforces that the response-body read size limit (response-size-read) is not negative. Negative MaxResponseBodySize is not a valid byte cap, so option validation fails before any HTTP requests are made.","triggerScenarios":"Passing -response-size-read with a negative value on the CLI, or setting Options.MaxResponseBodySize < 0 in code before ParseOptions.","commonSituations":"Automation scripts templating sizes with values that default to -1; misunderstanding the flag as 'unlimited' by using negative numbers (unlimited is configured differently).","solutions":["Provide a non-negative byte value for -response-size-read","Remove the flag to use the library default limit","If unlimited reads are intended, use the documented option for disabling the cap rather than a negative number"],"exampleFix":"// before\nsubfinder -d example.com -response-size-read -1024\n// after\nsubfinder -d example.com -response-size-read 1048576","handlingStrategy":"validation","validationCode":"if maxBodySize < 0 {\n    return fmt.Errorf(\"response-size-read must be >= 0, got %d\", maxBodySize)\n}","typeGuard":"func validBodySize(n int) bool { return n >= 0 }","tryCatchPattern":"opts, err := runner.ParseOptions()\nif err != nil && strings.Contains(err.Error(), \"response-size-read cannot be negative\") {\n    // correct the flag and re-parse\n}","preventionTips":["Pass non-negative byte sizes to -response-size-read","Don't use negative numbers to mean 'unlimited'","Sanitize values templated into scripts"],"tags":["cli","validation","options"],"backgroundTag":"invalid-flag-value","analyzedSha":"7a0b91f0fac01b62c65328bd771a3560ae611d6a","analyzedAt":"2026-09-06T23:52:02.109Z","contentChangedAt":"2026-09-06T23:52:02.109Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}