{"record":{"id":"c9f84ca1654302f9","repo":"crowdsecurity/crowdsec","slug":"unable-to-copy-s-to-s-w","errorCode":null,"errorMessage":"unable to copy '%s' to '%s': %w","messagePattern":"unable to copy '(.+?)' to '(.+?)': %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/hubtest/appsecrule.go","lineNumber":35,"sourceCode":"\t\treturn fmt.Errorf(\"can't get absolute path of '%s': %w\", sourcePath, err)\n\t}\n\n\tsourceFilename := filepath.Base(sourcePath)\n\n\t// runtime/hub/appsec-rules/author/appsec-rule\n\thubDirAppsecRuleDest := filepath.Join(t.RuntimeHubPath, filepath.Dir(item.RemotePath))\n\n\t// runtime/appsec-rules/\n\titemTypeDirDest := fmt.Sprintf(\"%s/appsec-rules/\", t.RuntimePath)\n\n\tif err := createDirs([]string{hubDirAppsecRuleDest, itemTypeDirDest}); err != nil {\n\t\treturn err\n\t}\n\n\t// runtime/hub/appsec-rules/crowdsecurity/rule.yaml\n\thubDirAppsecRulePath := filepath.Join(itemTypeDirDest, sourceFilename)\n\tif err := Copy(sourcePath, hubDirAppsecRulePath); err != nil {\n\t\treturn fmt.Errorf(\"unable to copy '%s' to '%s': %w\", sourcePath, hubDirAppsecRulePath, err)\n\t}\n\n\t// runtime/appsec-rules/rule.yaml\n\tappsecRulePath := filepath.Join(itemTypeDirDest, sourceFilename)\n\tif err := os.Symlink(hubDirAppsecRulePath, appsecRulePath); err != nil {\n\t\tif !os.IsExist(err) {\n\t\t\treturn fmt.Errorf(\"unable to symlink appsec-rule '%s' to '%s': %w\", hubDirAppsecRulePath, appsecRulePath, err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (t *HubTestItem) installAppsecRuleCustomFrom(appsecrule string, customPath string) (bool, error) {\n\t// we check if its a custom appsec-rule\n\tcustomAppsecRulePath := filepath.Join(customPath, appsecrule)\n\tif _, err := os.Stat(customAppsecRulePath); os.IsNotExist(err) {\n\t\treturn false, nil","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/hubtest/appsecrule.go#L17-L53","documentation":"installAppsecRuleItem copies the appsec-rule file from the hub source into the test runtime hub directory (Copy) and wraps any copy failure. The copy failing means the source file couldn't be read or the destination file couldn't be created/written.","triggerScenarios":"installAppsecRule on a hub item where the source HubPath/RemotePath file is missing or unreadable, or the destination hubDirAppsecRulePath under RuntimeHubPath is unwritable/inexistent despite createDirs.","commonSituations":"Incomplete or pruned hub checkout (source rule file absent); runtime directory owned by another user; disk full; test runtime path pointing at a read-only mount.","solutions":["Check the source file exists at HubPath + item.RemotePath and is readable; refresh the hub if not ('cscli hub update')","Verify permissions on the runtime hub destination directory and create it manually if needed","Check free disk space and that the destination filesystem is writable"],"exampleFix":"// before\nt := HubTestItem{HubPath: \"/old/hub\", RuntimeHubPath: \"/tmp/rt/hub\"}\n// after\nt := HubTestItem{HubPath: \"/etc/crowdsec/hub\", RuntimeHubPath: \"/tmp/rt/hub\"} // source rule present","handlingStrategy":"validation","validationCode":"src := filepath.Join(t.HubPath, item.RemotePath)\nif _, err := os.Stat(src); err != nil {\n\treturn fmt.Errorf(\"source appsec-rule missing: %s\", src)\n}\nif err := os.MkdirAll(t.RuntimeHubPath, 0o755); err != nil {\n\treturn err\n}","typeGuard":null,"tryCatchPattern":"if err := t.installAppsecRule(name); err != nil {\n\tif strings.Contains(err.Error(), \"unable to copy\") {\n\t\t// check source readability / destination writability before retry\n\t}\n\treturn err\n}","preventionTips":["Ensure the hub checkout is complete (no shallow/pruned clones missing rule files)","Pre-create runtime directories with correct ownership before test runs","Monitor disk space on CI runners"],"tags":["filesystem","file-copy","hub"],"backgroundTag":"file-copy-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"}