crowdsecurity/crowdsec · error
test '%s' doesn't exist in '%s', exiting
Error message
test '%s' doesn't exist in '%s', exiting
What it means
RunWithNucleiTemplate first checks that the test directory exists under HubTestPath before executing crowdsec commands for a nuclei-based test. If <HubTestPath>/<Name> is missing, it returns 'test <name> doesn't exist in <path>, exiting'. It is a preflight guard against running commands in a nonexistent runtime.
Source
Thrown at pkg/hubtest/hubtest_item.go:332
log.Infof("%s - %s", emoji.GreenCircle, line)
}
}
if len(failures) > 0 {
log.Errorf("Failure log -------------")
for _, line := range failures {
log.Infof("%s - %s", emoji.RedCircle, line)
}
}
return nil
}
func (t *HubTestItem) RunWithNucleiTemplate(ctx context.Context) error {
testPath := filepath.Join(t.HubTestPath, t.Name)
if _, err := os.Stat(testPath); os.IsNotExist(err) {
return fmt.Errorf("test '%s' doesn't exist in '%s', exiting", t.Name, t.HubTestPath)
}
crowdsecLogFile := filepath.Join(t.RuntimePath, "log", "crowdsec.log")
// machine add
cmdArgs := []string{"-c", t.RuntimeConfigFilePath, "machines", "add", "testMachine", "--force", "--auto"}
cscliRegisterCmd := exec.CommandContext(ctx, t.CscliPath, cmdArgs...)
cscliRegisterCmd.Dir = testPath
cscliRegisterCmd.Env = []string{"TESTDIR=" + testPath, "DATADIR=" + t.RuntimeHubConfig.InstallDataDir, "TZ=UTC"}
output, err := cscliRegisterCmd.CombinedOutput()
if err != nil {
if !strings.Contains(string(output), "unable to create machine: user 'testMachine': user already exist") {
fmt.Fprintln(os.Stdout, string(output))
return fmt.Errorf("fail to run '%s' for test '%s': %w", cscliRegisterCmd.String(), t.Name, err)
}
}
View on GitHub (pinned to 909b515798)
Solutions
- Verify the directory exists: `ls <HubTestPath>/<testName>`; if missing, re-clone/copy the hub tests or re-run the loader that creates the item.
- Correct the test name passed to Run so it matches an existing directory exactly.
- Ensure HubTestPath is set to the actual hub tests directory (check for typos/relative paths) before constructing/running the item.
- If a previous cleanup deleted it, recreate the test item via LoadTestItem before RunWithNucleiTemplate.
Example fix
null
Defensive patterns
Strategy: validation
Validate before calling
testPath := filepath.Join(hubTestPath, name)
if fi, err := os.Stat(testPath); err != nil || !fi.IsDir() {
return fmt.Errorf("test %s not present under %s", name, hubTestPath)
} Type guard
func testExists(hubTestPath, name string) bool {
fi, err := os.Stat(filepath.Join(hubTestPath, name))
return err == nil && fi.IsDir()
} Try / catch
err := item.Run(ctx)
if err != nil && strings.Contains(err.Error(), "doesn't exist in") {
// reload or re-clone the hub tests, then re-create the item via LoadTestItem
} Prevention
- Load the test item (LoadTestItem) before calling Run — don't run names that were never loaded.
- Verify HubTestPath points at the real hub tests directory.
- Avoid cleanup steps that delete test directories mid-suite.
When it happens
Trigger: Calling HubTestItem.Run (nuclei path) with a test whose directory was deleted, never created (LoadTestItem/NewTest not run or failed), or whose Name doesn't match an existing directory under HubTestPath.
Common situations: Typo in the test name; tests directory not copied/cloned into place; previous run cleaned up the test directory; running a hub test by name from the wrong working directory so HubTestPath points elsewhere.
Related errors
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/809c77e1ba1aa420.
Report an issue: GitHub.