{"record":{"id":"83a185df88b7b92b","repo":"projectdiscovery/subfinder","slug":"max-results-cannot-be-negative","errorCode":null,"errorMessage":"max-results cannot be negative","messagePattern":"max-results cannot be negative","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/runner/validate.go","lineNumber":45,"sourceCode":"\t\treturn errors.New(\"both verbose and silent mode specified\")\n\t}\n\n\t// Validate threads and options\n\tif options.Threads == 0 {\n\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))","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/projectdiscovery/subfinder/blob/7a0b91f0fac01b62c65328bd771a3560ae611d6a/pkg/runner/validate.go#L27-L63","documentation":"validateOptions enforces that the per-source results limit (max-results) is not negative. A negative MaxResults is meaningless as a cap, so option parsing fails fast with this error before enumeration starts.","triggerScenarios":"Supplying -max-results with a negative integer on the CLI, or programmatically setting Options.MaxResults < 0 before ParseOptions runs validation.","commonSituations":"Shell scripts computing the limit with variables that can go negative; typos like '-5' intended as a flag; copied config files with negative values.","solutions":["Pass a non-negative integer for -max-results","Omit the flag entirely to use the default limit","Validate any computed limit value before passing it to the runner"],"exampleFix":"// before\nsubfinder -d example.com -max-results -5\n// after\nsubfinder -d example.com -max-results 100","handlingStrategy":"validation","validationCode":"if maxResults < 0 {\n    return fmt.Errorf(\"max-results must be >= 0, got %d\", maxResults)\n}","typeGuard":"func validMaxResults(n int) bool { return n >= 0 }","tryCatchPattern":"opts, err := runner.ParseOptions()\nif err != nil && strings.Contains(err.Error(), \"max-results cannot be negative\") {\n    // fix flag value and retry parse\n}","preventionTips":["Never pass negative integers to -max-results","Validate computed limits in scripts before invoking subfinder","Rely on defaults when unsure"],"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"}