{"record":{"id":"d26cd377c85640cf","repo":"crowdsecurity/crowdsec","slug":"unable-to-copy-s-to-s-w-d26cd3","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/parser.go","lineNumber":33,"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/parsers/s00-raw/crowdsecurity/\n\thubDirParserDest := filepath.Join(t.RuntimeHubPath, filepath.Dir(item.RemotePath))\n\n\t// runtime/parsers/s00-raw/\n\titemTypeDirDest := fmt.Sprintf(\"%s/parsers/%s/\", t.RuntimePath, item.Stage)\n\n\tif err := createDirs([]string{hubDirParserDest, itemTypeDirDest}); err != nil {\n\t\treturn err\n\t}\n\n\t// runtime/hub/parsers/s00-raw/crowdsecurity/syslog-logs.yaml\n\thubDirParserPath := filepath.Join(hubDirParserDest, sourceFilename)\n\tif err := Copy(sourcePath, hubDirParserPath); err != nil {\n\t\treturn fmt.Errorf(\"unable to copy '%s' to '%s': %w\", sourcePath, hubDirParserPath, err)\n\t}\n\n\t// runtime/parsers/s00-raw/syslog-logs.yaml\n\tparserDirParserPath := filepath.Join(itemTypeDirDest, sourceFilename)\n\tif err := os.Symlink(hubDirParserPath, parserDirParserPath); err != nil {\n\t\tif !os.IsExist(err) {\n\t\t\treturn fmt.Errorf(\"unable to symlink parser '%s' to '%s': %w\", hubDirParserPath, parserDirParserPath, err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (t *HubTestItem) installParserCustomFrom(parser string, customPath string) (bool, error) {\n\t// we check if its a custom parser\n\tcustomParserPath := filepath.Join(customPath, parser)\n\tif _, err := os.Stat(customParserPath); os.IsNotExist(err) {\n\t\treturn false, nil","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/hubtest/parser.go#L15-L51","documentation":"After computing the destination inside the runtime hub, installParserItem copies the parser source file with Copy and wraps any copy failure. This means the parser file could not be read from the hub or written into runtime/hub/parsers/<stage>/ — a filesystem-level problem, not a config problem.","triggerScenarios":"Calling installParser when Copy(sourcePath, hubDirParserPath) fails: source file missing/renamed in the hub, destination directory absent (MkdirAll not reached or failed), disk full, or permission denied on the runtime directory.","commonSituations":"Hub not updated (`cscli hub update`) so RemotePath points to a nonexistent file; runtime dir owned by another user; read-only mount; running tests in parallel clobbering the runtime tree.","solutions":["Run `cscli hub update` / re-download the hub so the source parser file exists at HubPath/RemotePath.","Check permissions on the runtime hub directory and ensure the test user can write it.","Recreate the runtime directory (rm -rf runtime && re-run) to clear stale/partial state.","Check disk space with `df -h`."],"exampleFix":"// before\nhubtest.RunTests(hubPath, runtimePath, ...)\n// after\nif _, err := os.Stat(filepath.Join(hubPath, \"parsers\")); err != nil {\n\treturn fmt.Errorf(\"hub not present/corrupt at %s, run 'cscli hub update': %w\", hubPath, err)\n}\nhubtest.RunTests(hubPath, runtimePath, ...)","handlingStrategy":"validation","validationCode":"src := filepath.Join(hubPath, remotePath)\nif _, err := os.Stat(src); err != nil {\n\treturn fmt.Errorf(\"hub source file %s missing, run 'cscli hub update': %w\", src, err)\n}\nif err := os.MkdirAll(runtimeHubPath, 0o755); err != nil {\n\treturn err\n}","typeGuard":null,"tryCatchPattern":"if err := item.InstallParser(name); err != nil {\n\tif errors.Is(err, os.ErrPermission) {\n\t\t// fix ownership of runtime dir\n\t}\n\treturn err\n}","preventionTips":["Sync the hub before running tests.","Chown the runtime tree to the user running tests.","Check `df -h` in CI for disk exhaustion.","Recreate the runtime directory at the start of each run for a clean state."],"tags":["hubtest","file-copy","filesystem","permissions"],"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-14T00:17:10.932Z"}