{"record":{"id":"322e685e309ff8cf","repo":"shadow1ng/fscan","slug":"parser-parse-host-failed-w","errorCode":null,"errorMessage":"parser_parse_host_failed: %w","messagePattern":"parser_parse_host_failed: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/parsers/parsers.go","lineNumber":56,"sourceCode":"\tif filename != \"\" {\n\t\tfileHosts, err := ReadLinesFromFile(filename)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(i18n.GetText(\"parser_read_hosts_failed\")+\": %w\", err)\n\t\t}\n\t\tfor _, h := range fileHosts {\n\t\t\tparsed, err := parseHostString(h)\n\t\t\tif err != nil {\n\t\t\t\tcontinue // 跳过无效行\n\t\t\t}\n\t\t\thosts = append(hosts, parsed...)\n\t\t}\n\t}\n\n\t// 解析主机参数\n\tif host != \"\" {\n\t\thostList, err := parseHostString(host)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(i18n.GetText(\"parser_parse_host_failed\")+\": %w\", err)\n\t\t}\n\t\thosts = append(hosts, hostList...)\n\t}\n\n\t// 处理排除主机\n\tif len(nohosts) > 0 {\n\t\tmatcher := newHostMatcher()\n\t\thasExclude := false\n\t\tfor _, exclude := range nohosts {\n\t\t\tif strings.TrimSpace(exclude) == \"\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\thasExclude = true\n\t\t\tif err := matcher.add(exclude); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(i18n.GetText(\"parser_parse_exclude_failed\")+\": %w\", err)\n\t\t\t}\n\t\t}\n\t\tif hasExclude {","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/common/parsers/parsers.go#L38-L74","documentation":"ParseIP parses the comma-separated host argument (IPs, CIDRs, ranges, shorthands like '192') via parseHostString. If that returns an error, ParseIP wraps it with 'parser_parse_host_failed', meaning one of the host expressions in the -h argument could not be parsed.","triggerScenarios":"Calling ParseIP with host containing a malformed CIDR (e.g. '10.0.0.0/33') or malformed IP range (e.g. '192.168.1.5-1.2'), which makes the inner parseIPCIDR/parseIPRangeString fail and bubbles up wrapped.","commonSituations":"Hand-written target lists with typos (bad netmask, reversed range like 192.168.1.100-192.168.1.10), or leftover shell characters in the -h argument.","solutions":["Inspect the wrapped inner error (%w) to find which expression failed","Fix the offending CIDR/range syntax (e.g. /0-/32 mask, start<=end)","Validate the host string before calling ParseIP (see validationCode)","Split the comma list and parse each target individually to isolate the bad one"],"exampleFix":"// before\nParseIP(\"192.168.1.0/33\", \"\")\n// after\nParseIP(\"192.168.1.0/24\", \"\")","handlingStrategy":"try-catch","validationCode":"for _, h := range strings.Split(host, \",\") {\n\th = strings.TrimSpace(h)\n\tif strings.Contains(h, \"/\") {\n\t\tif _, _, err := net.ParseCIDR(h); err != nil { return fmt.Errorf(\"bad CIDR %q\", h) }\n\t}\n}","typeGuard":null,"tryCatchPattern":"hosts, err := parsers.ParseIP(host, file)\nif err != nil {\n\tif strings.Contains(err.Error(), \"parser_parse_host_failed\") {\n\t\tlog.Fatalf(\"invalid -h value %q: %v\", host, err)\n\t}\n\treturn err\n}","preventionTips":["Validate each comma-separated target before calling ParseIP","Keep netmasks within /0-/32","Avoid extra whitespace and stray shell characters in the -h argument"],"tags":["ip-parsing","argument-validation","wraps-error"],"backgroundTag":"invalid-argument-format","analyzedSha":"95cc12e753bf43de7004e5aef42a9ffba3934303","analyzedAt":"2026-09-06T17:07:30.094Z","contentChangedAt":"2026-09-06T17:07:30.094Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}