{"record":{"id":"ff46cf25330f68fb","repo":"crowdsecurity/crowdsec","slug":"unable-to-copy-s-to-s-w-ff46cf","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/scenario.go","lineNumber":32,"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/scenarios/crowdsecurity/\n\thubDirScenarioDest := filepath.Join(t.RuntimeHubPath, filepath.Dir(item.RemotePath))\n\n\t// runtime/parsers/scenarios/\n\titemTypeDirDest := fmt.Sprintf(\"%s/scenarios/\", t.RuntimePath)\n\n\tif err := createDirs([]string{hubDirScenarioDest, itemTypeDirDest}); err != nil {\n\t\treturn err\n\t}\n\n\t// runtime/hub/scenarios/crowdsecurity/ssh-bf.yaml\n\thubDirScenarioPath := filepath.Join(hubDirScenarioDest, sourceFilename)\n\tif err := Copy(sourcePath, hubDirScenarioPath); err != nil {\n\t\treturn fmt.Errorf(\"unable to copy '%s' to '%s': %w\", sourcePath, hubDirScenarioPath, err)\n\t}\n\n\t// runtime/scenarios/ssh-bf.yaml\n\tscenarioDirParserPath := filepath.Join(itemTypeDirDest, sourceFilename)\n\tif err := os.Symlink(hubDirScenarioPath, scenarioDirParserPath); err != nil {\n\t\tif !os.IsExist(err) {\n\t\t\treturn fmt.Errorf(\"unable to symlink scenario '%s' to '%s': %w\", hubDirScenarioPath, scenarioDirParserPath, err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (t *HubTestItem) installScenarioCustomFrom(scenario string, customPath string) (bool, error) {\n\t// we check if its a custom scenario\n\tcustomScenarioPath := filepath.Join(customPath, scenario)\n\tif _, err := os.Stat(customScenarioPath); os.IsNotExist(err) {\n\t\treturn false, nil","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/hubtest/scenario.go#L14-L50","documentation":"installScenarioItem copies the scenario file from the hub directory (RuntimeHubPath) into the test's runtime hub scenarios directory. If the file copy fails (Copy wraps os-level create/read/copy errors), this error reports both source and destination paths plus the underlying cause. Typical causes are missing directories, permission problems, or the source file not existing.","triggerScenarios":"installScenario -> installScenarioItem where Copy(sourcePath, hubDirScenarioPath) fails: the hub scenario file is absent, the destination directory doesn't exist/hasn't been created with correct permissions, or disk is full.","commonSituations":"Corrupted or partially updated hub (cscli hub update interrupted); read-only filesystem or container; the test runtime directory was pre-created by root and tests run as another user.","solutions":["Check the wrapped error to identify whether the source is missing or the destination is unwritable.","Re-download the hub: 'cscli hub update' then re-run the test.","Fix permissions/ownership on the runtime hub directory (or run as the right user).","Ensure the parent destination directory exists before Copy (MkdirAll was done earlier; verify it succeeded)."],"exampleFix":"// before\nif err := Copy(sourcePath, hubDirScenarioPath); err != nil {\n\treturn fmt.Errorf(\"unable to copy '%s' to '%s': %w\", sourcePath, hubDirScenarioPath, err)\n}\n// after\nif err := os.MkdirAll(filepath.Dir(hubDirScenarioPath), os.ModePerm); err != nil {\n\treturn err\n}\nif err := Copy(sourcePath, hubDirScenarioPath); err != nil {\n\treturn fmt.Errorf(\"unable to copy '%s' to '%s': %w\", sourcePath, hubDirScenarioPath, err)\n}","handlingStrategy":"try-catch","validationCode":"if _, err := os.Stat(sourcePath); err != nil {\n\treturn fmt.Errorf(\"hub scenario missing: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := Copy(sourcePath, dest); err != nil {\n\tvar perr *os.PathError\n\tif errors.As(err, &perr) && os.IsPermission(err) {\n\t\treturn fmt.Errorf(\"fix permissions on %s: %w\", filepath.Dir(dest), err)\n\t}\n\treturn err\n}","preventionTips":["Run 'cscli hub update' before tests so the hub tree is complete.","Run tests as a user with write access to the runtime directory.","Check disk space in CI before long test runs."],"tags":["crowdsec","hub","filesystem","file-copy"],"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"}