crowdsecurity/crowdsec · error

couldn't find custom parser '%s' in the following locations:

Error message

couldn't find custom parser '%s' in the following locations: %+v

What it means

installParserCustom searches each directory in HubTestItem.CustomItemsLocation for a file named after the requested parser; if none is found anywhere, it reports all searched locations. It means the custom parser is not registered where hubtest looks — an explicit configuration/layout issue, since the name was also not in the hub index (otherwise installParserItem would have run).

Source

Thrown at pkg/hubtest/parser.go:91

		return false, fmt.Errorf("unable to copy custom parser '%s' to '%s': %w", customParserPath, customParserDest, err)
	}

	return true, nil
}

func (t *HubTestItem) installParserCustom(parser string) error {
	for _, customPath := range t.CustomItemsLocation {
		found, err := t.installParserCustomFrom(parser, customPath)
		if err != nil {
			return err
		}

		if found {
			return nil
		}
	}

	return fmt.Errorf("couldn't find custom parser '%s' in the following locations: %+v", parser, t.CustomItemsLocation)
}

func (t *HubTestItem) installParser(name string) error {
	if item := t.HubIndex.GetItem(cwhub.PARSERS, name); item != nil {
		return t.installParserItem(item)
	}

	return t.installParserCustom(name)
}

View on GitHub (pinned to 909b515798)

Solutions

  1. Set CustomItemsLocation (cscli hubtest run --custom-items-location <dir>) to the directory containing the parser file.
  2. Verify the file name matches the parser name exactly (including .yaml extension handling): `ls <custom-dir>/<name>*`.
  3. If it's a hub parser, confirm it exists: `cscli parsers list | grep <name>`, and update the hub if missing.

Example fix

// before
item.CustomItemsLocation = []string{} // unset
item.InstallParser("my-custom-parser")
// after
item.CustomItemsLocation = []string{"./.tests/custom/parsers"}
item.InstallParser("my-custom-parser")
Defensive patterns

Strategy: validation

Validate before calling

var found string
for _, dir := range item.CustomItemsLocation {
	if _, err := os.Stat(filepath.Join(dir, parser)); err == nil {
		found = filepath.Join(dir, parser)
		break
	}
}
if found == "" {
	return fmt.Errorf("custom parser %s not found in %v", parser, item.CustomItemsLocation)
}

Try / catch

if err := item.InstallParser(name); err != nil {
	if strings.Contains(err.Error(), "couldn't find custom parser") {
		// fix CustomItemsLocation or the parser name
	}
	return err
}

Prevention

When it happens

Trigger: Calling installParser with a name that is neither in the hub index nor present as <name>(.yaml) in any directory listed in CustomItemsLocation.

Common situations: Forgot to set --custom-items-location / CustomItemsLocation; parser filename doesn't match the requested name (my-parser vs my_parser); parser exists in hub but under a different item type; typo in the parser name.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06). Data as JSON: /api/errors/a4c5b5c2db756b60. Report an issue: GitHub.