{"record":{"id":"e7b480c0ef5c56db","repo":"crowdsecurity/crowdsec","slug":"log-file-or-nuclei-template-must-be-set-in-s","errorCode":null,"errorMessage":"log file or nuclei template must be set in '%s'","messagePattern":"log file or nuclei template must be set in '(.+?)'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/hubtest/hubtest_item.go","lineNumber":675,"sourceCode":"\t\tif err = os.WriteFile(t.RuntimeAcquisFilePath, []byte(\"\"), os.ModePerm); err != nil {\n\t\t\treturn fmt.Errorf(\"unable to write blank acquis file '%s': %w\", t.RuntimeAcquisFilePath, err)\n\t\t}\n\t}\n\n\t// install the hub in the runtime folder\n\tif err = t.InstallHub(ctx); err != nil {\n\t\treturn fmt.Errorf(\"unable to install hub in '%s': %w\", t.RuntimeHubPath, err)\n\t}\n\n\tif t.Config.LogFile != \"\" {\n\t\treturn t.RunWithLogFile(ctx)\n\t}\n\n\tif t.Config.NucleiTemplate != \"\" {\n\t\treturn t.RunWithNucleiTemplate(ctx)\n\t}\n\n\treturn fmt.Errorf(\"log file or nuclei template must be set in '%s'\", t.Name)\n}\n","sourceCodeStart":657,"sourceCodeEnd":677,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/hubtest/hubtest_item.go#L657-L677","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Add a `log_file` entry pointing at the log fixture in the test's config file.","Alternatively set `nuclei_template` if the test is driven by a nuclei template.","Check the config key spelling — an unrecognized key is silently ignored, leaving the field empty.","Regenerate the test skeleton with `cscli hubtest create` and fill in the log file path."],"exampleFix":"// before: tests/mytest/config.yaml\n// (no log_file, no nuclei_template)\n// after\ncfg := HubtestConfig{\n    LogFile: \"./tests/mytest/logs/app.log\", // or NucleiTemplate: \"./template.yaml\"\n    // ...\n}","handlingStrategy":"validation","validationCode":"func validateTestConfig(cfg HubtestConfig, name string) error {\n    if cfg.LogFile == \"\" && cfg.NucleiTemplate == \"\" {\n        return fmt.Errorf(\"test %s needs log_file or nuclei_template\", name)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if err := item.Run(ctx, patternDir); err != nil {\n    if strings.Contains(err.Error(), \"log file or nuclei template must be set\") {\n        return fmt.Errorf(\"fix config for test %s: %w\", item.Name, err)\n    }\n    return err\n}","preventionTips":["Always define `log_file` or `nuclei_template` in a test's config file.","Watch key spelling — unknown config keys are silently ignored.","Add a config validation pass over all hubtest items before running the suite.","Scaffold new tests with `cscli hubtest create` so required fields are present."],"tags":["go","hubtest","config","validation"],"backgroundTag":"missing-required-config","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}