{"record":{"id":"1cc90a31cec5bda8","repo":"crowdsecurity/crowdsec","slug":"can-t-get-absolute-path-of-s-w-1cc90a","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/parser.go","lineNumber":15,"sourceCode":"package hubtest\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"strings\"\n\n\t\"github.com/crowdsecurity/crowdsec/pkg/cwhub\"\n)\n\nfunc (t *HubTestItem) installParserItem(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/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)","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/hubtest/parser.go#L1-L33","documentation":"installParserItem resolves the hub item's source file to an absolute path via filepath.Abs and wraps any failure from that call. filepath.Abs only fails when Getwd fails (e.g. the working directory was deleted) or the joined path is malformed, so this error almost always indicates an environment/cwd problem rather than a bad item name.","triggerScenarios":"Calling HubTestItem.installParser for an item whose HubPath+RemotePath join makes filepath.Abs fail — practically only when os.Getwd() errors (deleted current directory, permission issue) or the path contains invalid components.","commonSituations":"Running hub tests from a temp dir that was removed mid-run; running with a cwd the process cannot stat; HubPath built from an empty/incorrect config producing a broken join.","solutions":["Check that the current working directory exists and is accessible (re-run from a valid directory).","Verify t.HubPath is a correct absolute path in the test config (cscli hubtest flags).","Confirm the item's RemotePath exists under HubPath: `ls <HubPath>/<RemotePath>`."],"exampleFix":"// before\ncwd, _ := os.Getwd() // may be empty if cwd deleted\nrunTests(cwd)\n// after\ncwd, err := os.Getwd()\nif err != nil {\n\treturn fmt.Errorf(\"working directory unavailable: %w\", err)\n}\nrunTests(cwd)","handlingStrategy":"validation","validationCode":"if cwd, err := os.Getwd(); err != nil {\n\treturn fmt.Errorf(\"cwd unavailable: %w\", err)\n}\nif _, err := os.Stat(filepath.Join(hubPath, itemRemotePath)); err != nil {\n\treturn fmt.Errorf(\"hub item missing at %s: %w\", filepath.Join(hubPath, itemRemotePath), err)\n}","typeGuard":null,"tryCatchPattern":"if err := item.InstallParser(name); err != nil {\n\t// absolute-path or copy failure: check cwd and hub integrity\n\treturn fmt.Errorf(\"install parser %s: %w\", name, err)\n}","preventionTips":["Run hubtests from a stable, existing working directory.","Keep HubPath absolute in test configuration.","Run `cscli hub update` before test runs."],"tags":["hubtest","filesystem","path-resolution"],"backgroundTag":"file-read-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"}