{"record":{"id":"12b24625cc1b6129","repo":"crowdsecurity/crowdsec","slug":"can-t-get-absolute-path-of-s-w-12b246","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/postoverflow.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) installPostoverflowItem(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/postoverflows/s00-enrich/crowdsecurity/\n\thubDirPostoverflowDest := filepath.Join(t.RuntimeHubPath, filepath.Dir(item.RemotePath))\n\n\t// runtime/postoverflows/s00-enrich\n\titemTypeDirDest := fmt.Sprintf(\"%s/postoverflows/%s/\", t.RuntimePath, item.Stage)\n\n\tif err := createDirs([]string{hubDirPostoverflowDest, itemTypeDirDest}); err != nil {\n\t\treturn err\n\t}\n\n\t// runtime/hub/postoverflows/s00-enrich/crowdsecurity/rdns.yaml\n\thubDirPostoverflowPath := filepath.Join(hubDirPostoverflowDest, sourceFilename)\n\tif err := Copy(sourcePath, hubDirPostoverflowPath); err != nil {\n\t\treturn fmt.Errorf(\"unable to copy '%s' to '%s': %w\", sourcePath, hubDirPostoverflowPath, err)","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/hubtest/postoverflow.go#L1-L33","documentation":"installPostoverflowItem computes the absolute path of a hub postoverflow item (HubPath + RemotePath) to copy it into the test runtime hub. filepath.Abs fails only in exotic conditions (e.g. issues resolving the working directory), and the item's RemotePath is reported for debugging. It aborts the hub test item install.","triggerScenarios":"installPostoverflowItem invoked with an item whose combined HubPath/RemotePath cannot be resolved to an absolute path — essentially when the process working directory is invalid or HubPath is empty/malformed.","commonSituations":"Test item configured with an empty HubPath field; running tests from a deleted working directory; misconfigured hub path in the hubtest definition.","solutions":["Verify the test item's HubPath points to an existing, absolute hub directory","Run the tests from a valid working directory","Check the item's RemotePath is set (populated by hub load)","Print/validate t.HubPath before the install call"],"exampleFix":"// before\nif t.HubPath == \"\" { ... later Abs fails ... }\n// after\nif t.HubPath == \"\" {\n    return fmt.Errorf(\"HubPath is empty, cannot install postoverflow\")\n}","handlingStrategy":"validation","validationCode":"if t.HubPath == \"\" {\n    return fmt.Errorf(\"HubPath must be set before installing postoverflows\")\n}\nif _, err := os.Stat(filepath.Join(t.HubPath, item.RemotePath)); err != nil {\n    return fmt.Errorf(\"hub item missing: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := t.installPostoverflow(item); err != nil {\n    if strings.Contains(err.Error(), \"can't get absolute path\") {\n        log.Errorf(\"bad hub path config: %v\", err)\n    }\n    return err\n}","preventionTips":["Initialize HubPath with an absolute directory before constructing HubTestItem","Ensure RemotePath is populated by the hub loader before install","Run hub tests from a valid, existing working directory"],"tags":["filesystem","hubtest","path"],"backgroundTag":"file-not-found","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"}