crowdsecurity/crowdsec · error

log file or nuclei template must be set in '%s'

Error message

log file or nuclei template must be set in '%s'

What it means

This error is returned at the end of HubTestItem.Run when neither a log file nor a nuclei template is configured for the test item. After setting up the runtime environment, Run dispatches to RunWithLogFile or RunWithNucleiTemplate; with both t.Config.LogFile and t.Config.NucleiTemplate empty there is nothing to run, so Run fails with this validation message naming the test.

Source

Thrown at pkg/hubtest/hubtest_item.go:675

		if err = os.WriteFile(t.RuntimeAcquisFilePath, []byte(""), os.ModePerm); err != nil {
			return fmt.Errorf("unable to write blank acquis file '%s': %w", t.RuntimeAcquisFilePath, err)
		}
	}

	// install the hub in the runtime folder
	if err = t.InstallHub(ctx); err != nil {
		return fmt.Errorf("unable to install hub in '%s': %w", t.RuntimeHubPath, err)
	}

	if t.Config.LogFile != "" {
		return t.RunWithLogFile(ctx)
	}

	if t.Config.NucleiTemplate != "" {
		return t.RunWithNucleiTemplate(ctx)
	}

	return fmt.Errorf("log file or nuclei template must be set in '%s'", t.Name)
}

View on GitHub (pinned to 909b515798)

Solutions

  1. Add a `log_file` entry pointing at the log fixture in the test's config file.
  2. Alternatively set `nuclei_template` if the test is driven by a nuclei template.
  3. Check the config key spelling — an unrecognized key is silently ignored, leaving the field empty.
  4. Regenerate the test skeleton with `cscli hubtest create` and fill in the log file path.

Example fix

// before: tests/mytest/config.yaml
// (no log_file, no nuclei_template)
// after
cfg := HubtestConfig{
    LogFile: "./tests/mytest/logs/app.log", // or NucleiTemplate: "./template.yaml"
    // ...
}
Defensive patterns

Strategy: validation

Validate before calling

func validateTestConfig(cfg HubtestConfig, name string) error {
    if cfg.LogFile == "" && cfg.NucleiTemplate == "" {
        return fmt.Errorf("test %s needs log_file or nuclei_template", name)
    }
    return nil
}

Try / catch

if err := item.Run(ctx, patternDir); err != nil {
    if strings.Contains(err.Error(), "log file or nuclei template must be set") {
        return fmt.Errorf("fix config for test %s: %w", item.Name, err)
    }
    return err
}

Prevention

When it happens

Trigger: Running a hubtest whose tests/<name>/meta or config defines neither `log_file` nor `nuclei_template`, so after InstallHub both dispatch branches are skipped and the terminal error is returned.

Common situations: A newly created test folder with an incomplete config file; a config typo'd key (e.g. `logfile` instead of `log_file`) silently leaving the field empty; copying a test template and forgetting to point it at a log file; removing a nuclei template reference without adding a log file.

Understand the failure class

Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.

Related errors


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