{"record":{"id":"0fc982a618cda349","repo":"crowdsecurity/crowdsec","slug":"can-t-get-absolute-path-of-s-w-0fc982","errorCode":null,"errorMessage":"can't get absolute path of '%s': %w","messagePattern":"can't get absolute path of '(.+?)': %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/hubtest/scenario.go","lineNumber":14,"sourceCode":"package hubtest\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"path/filepath\"\n\n\t\"github.com/crowdsecurity/crowdsec/pkg/cwhub\"\n)\n\nfunc (t *HubTestItem) installScenarioItem(item *cwhub.Item) error {\n\tsourcePath, err := filepath.Abs(filepath.Join(t.HubPath, item.RemotePath))\n\tif err != nil {\n\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)","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/hubtest/scenario.go#L1-L32","documentation":"installScenarioItem resolves the absolute path of a hub scenario by joining the hub root with the item's RemotePath. filepath.Abs only fails when the current working directory cannot be determined (or in rare syscall errors). The error wraps that failure while naming the path being resolved.","triggerScenarios":"Calling installScenario -> installScenarioItem when the OS cannot determine the process working directory (deleted cwd), so filepath.Abs returns an error.","commonSituations":"Running crowdsec/ci tests from a directory that has been removed or replaced (common in containers or when the test harness deletes its own cwd); very unusual on healthy systems.","solutions":["Run the process from an existing, accessible working directory.","In containers/scripts, ensure the cwd is not deleted before the test runs (cd to a valid dir first).","Inspect the wrapped error (%w) to confirm it is syscall.ENOENT on the cwd."],"exampleFix":"// before\ncd /tmp/workdir && rm -rf /tmp/workdir && ./crowdsec test run ...\n// after\ncd /tmp && ./crowdsec test run ...","handlingStrategy":"try-catch","validationCode":"if wd, err := os.Getwd(); err != nil || wd == \"\" {\n\t// resolve paths relative to an explicit root instead of relying on cwd\n}","typeGuard":null,"tryCatchPattern":"if _, err := os.Getwd(); err != nil {\n\treturn fmt.Errorf(\"working directory unavailable: %w\", err)\n}","preventionTips":["Never delete the process's own working directory in scripts/CI.","Pass absolute hub paths so filepath.Abs is trivially safe."],"tags":["crowdsec","hub","filesystem","testing"],"backgroundTag":"file-open-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"}