{"record":{"id":"4cb8540928425c03","repo":"crowdsecurity/crowdsec","slug":"unable-to-write-blank-acquis-file-s-w","errorCode":null,"errorMessage":"unable to write blank acquis file '%s': %w","messagePattern":"unable to write blank acquis file '(.+?)': %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/hubtest/hubtest_item.go","lineNumber":658,"sourceCode":"\t}\n\n\t// if it's an appsec rule test, we need acquis and appsec profile\n\tif len(t.Config.AppsecRules) > 0 {\n\t\t// copy template acquis file to runtime folder\n\t\tlog.Debugf(\"copying %s to %s\", t.TemplateAcquisPath, t.RuntimeAcquisFilePath)\n\n\t\tif err = Copy(t.TemplateAcquisPath, t.RuntimeAcquisFilePath); err != nil {\n\t\t\treturn fmt.Errorf(\"unable to copy '%s' to '%s': %w\", t.TemplateAcquisPath, t.RuntimeAcquisFilePath, err)\n\t\t}\n\n\t\tlog.Debugf(\"copying %s to %s\", t.TemplateAppsecProfilePath, filepath.Join(t.RuntimePath, \"appsec-configs\", \"config.yaml\"))\n\t\t// copy template appsec-config file to runtime folder\n\t\tif err = Copy(t.TemplateAppsecProfilePath, filepath.Join(t.RuntimePath, \"appsec-configs\", \"config.yaml\")); err != nil {\n\t\t\treturn fmt.Errorf(\"unable to copy '%s' to '%s': %w\", t.TemplateAppsecProfilePath, filepath.Join(t.RuntimePath, \"appsec-configs\", \"config.yaml\"), err)\n\t\t}\n\t} else { // otherwise we drop a blank acquis file\n\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}","sourceCodeStart":640,"sourceCodeEnd":676,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/hubtest/hubtest_item.go#L640-L676","documentation":"This error is returned by HubTestItem.Run for non-appsec tests when writing the blank acquisition file (os.WriteFile of an empty string to t.RuntimeAcquisFilePath) fails. Crowdsec still needs an acquis file to start, so tests without appsec rules get an empty one; the write failure wraps the OS error.","triggerScenarios":"HubTestItem.Run with no AppsecRules configured, and the runtime acquis path is unwritable, its parent directory was removed mid-run, or the destination exists as a directory.","commonSituations":"Runtime folder deleted between createDirs and the write (concurrent test runs sharing a runtime path); permission changes mid-run; read-only mount or full disk during CI.","solutions":["Check the wrapped error: for permission issues, fix ownership/permissions on the runtime directory.","Ensure no concurrent test runs share the same t.RuntimePath; isolate runtime folders per test.","Remove stale runtime folders and re-run.","Check that t.RuntimeAcquisFilePath is not an existing directory and disk space is available."],"exampleFix":"// before\nitem.Run(ctx, patternDir) // \"unable to write blank acquis file ...: permission denied\"\n// after: ensure writable runtime before running\nif err := os.Chmod(item.RuntimePath, 0o755); err != nil { ... }\nif err := item.Run(ctx, patternDir); err != nil { ... }","handlingStrategy":"validation","validationCode":"if err := os.MkdirAll(filepath.Dir(item.RuntimeAcquisFilePath), 0o755); err != nil {\n    return fmt.Errorf(\"acquis dir not writable: %w\", err)\n}\nif fi, err := os.Stat(item.RuntimeAcquisFilePath); err == nil && fi.IsDir() {\n    return fmt.Errorf(\"%s is a directory\", item.RuntimeAcquisFilePath)\n}","typeGuard":null,"tryCatchPattern":"if err := item.Run(ctx, patternDir); err != nil {\n    if os.IsPermission(errors.Unwrap(err)) {\n        return fmt.Errorf(\"fix permissions on %s: %w\", item.RuntimePath, err)\n    }\n    return err\n}","preventionTips":["Do not run concurrent hub tests sharing one runtime path.","Ensure the runtime directory is writable before invoking Run.","Check that the acquis destination path is a file, not a directory.","Verify disk space and mount status in CI environments."],"tags":["go","file-write","hubtest","acquis"],"backgroundTag":"file-write-failed","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}