{"record":{"id":"a7800fb638ebdb04","repo":"owasp-amass/amass","slug":"invalid-port-range-format","errorCode":null,"errorMessage":"invalid port range format","messagePattern":"invalid port range format","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/scope.go","lineNumber":135,"sourceCode":"\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"invalid port string: %v\", err)\n\t\t\t\t}\n\t\t\t\ts.Ports = append(s.Ports, portNum)\n\t\t\t}\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"unsupported port type: %T\", p)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc convertPortRangeToSlice(portRange string) ([]int, error) {\n\tvar ports []int\n\n\tparts := strings.Split(portRange, \"-\")\n\tif len(parts) != 2 {\n\t\treturn nil, fmt.Errorf(\"invalid port range format\")\n\t}\n\n\tstart, err := strconv.Atoi(parts[0])\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid start port: %v\", err)\n\t}\n\n\tend, err := strconv.Atoi(parts[1])\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid end port: %v\", err)\n\t}\n\n\tfor i := start; i <= end; i++ {\n\t\tports = append(ports, i)\n\t}\n\n\treturn ports, nil\n}","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/config/scope.go#L117-L153","documentation":"convertPortRangeToSlice splits a range string on '-' and requires exactly two parts (start and end). This error is returned for strings that do not match the 'N-M' format, such as missing dashes or extra dashes.","triggerScenarios":"A port entry like '80-90-100', '80--90', '80-' or '-90' is passed to parsePorts and routed to convertPortRangeToSlice; strings.Split yields a part count other than 2.","commonSituations":"Chained ranges in config (80-85-90), trailing/leading hyphens from manual editing, negative-looking numbers, or typos like '8O-90' with two delimiters.","solutions":["Write the range as exactly start-end with one hyphen, e.g. '80-90'","Remove extra hyphens or chained ranges; use separate entries for non-contiguous ports","Ensure neither side of the hyphen is empty"],"exampleFix":"// before\nports: [\"80-90-100\"]\n// after\nports: [\"80-90\", \"100\"]","handlingStrategy":"validation","validationCode":"matched, _ := regexp.MatchString(`^\\d+-\\d+$`, s); if !matched { return fmt.Errorf(\"port range must be N-M: %q\", s) }","typeGuard":"func isPortRange(s string) bool { m, _ := regexp.MatchString(`^\\d+-\\d+$`, s); return m }","tryCatchPattern":null,"preventionTips":["Exactly one hyphen per range","No chained ranges like 80-85-90","Regexp-validate range strings before config load","Quote YAML values to avoid parse surprises"],"tags":["config","ports","format"],"backgroundTag":"invalid-argument-format","analyzedSha":"79299dce87b0085db0f2f4ef3e9c52cccb49f514","analyzedAt":"2026-09-06T08:22:48.198Z","contentChangedAt":"2026-09-06T08:22:48.198Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}