shadow1ng/fscan · error

parser_parse_exclude_failed: %w

Error message

parser_parse_exclude_failed: %w

What it means

ParseIP applies exclusions via hostMatcher.add for each -nohosts entry. If adding an exclusion expression fails (malformed CIDR or range inside the exclusion list), the error is wrapped with 'parser_parse_exclude_failed'. It means the exclude list, not the target list, contains an invalid expression.

Source

Thrown at common/parsers/parsers.go:71

	if host != "" {
		hostList, err := parseHostString(host)
		if err != nil {
			return nil, fmt.Errorf(i18n.GetText("parser_parse_host_failed")+": %w", err)
		}
		hosts = append(hosts, hostList...)
	}

	// 处理排除主机
	if len(nohosts) > 0 {
		matcher := newHostMatcher()
		hasExclude := false
		for _, exclude := range nohosts {
			if strings.TrimSpace(exclude) == "" {
				continue
			}
			hasExclude = true
			if err := matcher.add(exclude); err != nil {
				return nil, fmt.Errorf(i18n.GetText("parser_parse_exclude_failed")+": %w", err)
			}
		}
		if hasExclude {
			hosts = excludeFromList(hosts, matcher)
		}
	}

	// 去重和排序
	hosts = removeDuplicateStrings(hosts)
	sort.Strings(hosts)

	if len(hosts) == 0 {
		return nil, fmt.Errorf("%s", i18n.GetText("parser_no_valid_hosts"))
	}

	return hosts, nil
}

View on GitHub (pinned to 95cc12e753)

Solutions

  1. Check the wrapped inner error to identify the bad exclusion entry
  2. Correct the CIDR/range syntax in the -nohosts value
  3. Remove the invalid entry if the exclusion is optional
  4. Validate each exclusion string with net.ParseCIDR or the range grammar before calling ParseIP

Example fix

// before
ParseIP("10.0.0.0/8", "", "10.0.0.0/33")
// after
ParseIP("10.0.0.0/8", "", "10.0.0.5/32")
Defensive patterns

Strategy: validation

Validate before calling

for _, ex := range nohosts {
	if strings.Contains(ex, "/") {
		if _, _, err := net.ParseCIDR(strings.TrimSpace(ex)); err != nil {
			return fmt.Errorf("bad exclusion CIDR %q", ex)
		}
	}
}

Try / catch

hosts, err := parsers.ParseIP(host, file, nohosts...)
if err != nil {
	if strings.Contains(err.Error(), "parser_parse_exclude_failed") {
		log.Printf("bad exclusion entry: %v", err)
	}
	return err
}

Prevention

When it happens

Trigger: Calling ParseIP(host, file, "10.0.0.0/33") or any nohosts entry whose CIDR/range part fails to parse — matcher.add returns the inner error which is wrapped here.

Common situations: Copy-pasted exclusion lists with a bad netmask, an IPv6 CIDR passed to an IPv4-only matcher, or a broken range like '192.168.1.100-192.168.1.1'.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of shadow1ng/fscan@95cc12e753 (2026-09-06). Data as JSON: /api/errors/e1ca2b5024478a0f. Report an issue: GitHub.