{"record":{"id":"c6a50d805c1084fe","repo":"crowdsecurity/crowdsec","slug":"unable-to-copy-custom-parser-s-to-s-w","errorCode":null,"errorMessage":"unable to copy custom parser '%s' to '%s': %w","messagePattern":"unable to copy custom parser '(.+?)' to '(.+?)': %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/hubtest/parser.go","lineNumber":73,"sourceCode":"\t// because path is parsers/<stage>/<author>/parser.yaml and we wan't the stage\n\tsplitPath := strings.Split(customParserPathSplit, string(os.PathSeparator))\n\tcustomParserStage := splitPath[len(splitPath)-3]\n\n\t// check if stage exist\n\thubStagePath := filepath.Join(t.HubPath, fmt.Sprintf(\"parsers/%s\", customParserStage))\n\tif _, err := os.Stat(hubStagePath); os.IsNotExist(err) {\n\t\treturn false, fmt.Errorf(\"stage '%s' extracted from '%s' doesn't exist in the hub\", customParserStage, hubStagePath)\n\t}\n\n\tstageDirDest := fmt.Sprintf(\"%s/parsers/%s/\", t.RuntimePath, customParserStage)\n\tif err := os.MkdirAll(stageDirDest, os.ModePerm); err != nil {\n\t\treturn false, fmt.Errorf(\"unable to create folder '%s': %w\", stageDirDest, err)\n\t}\n\n\tcustomParserDest := filepath.Join(stageDirDest, customParserName)\n\t// if path to parser exist, copy it\n\tif err := Copy(customParserPath, customParserDest); err != nil {\n\t\treturn false, fmt.Errorf(\"unable to copy custom parser '%s' to '%s': %w\", customParserPath, customParserDest, err)\n\t}\n\n\treturn true, nil\n}\n\nfunc (t *HubTestItem) installParserCustom(parser string) error {\n\tfor _, customPath := range t.CustomItemsLocation {\n\t\tfound, err := t.installParserCustomFrom(parser, customPath)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif found {\n\t\t\treturn nil\n\t\t}\n\t}\n\n\treturn fmt.Errorf(\"couldn't find custom parser '%s' in the following locations: %+v\", parser, t.CustomItemsLocation)","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/hubtest/parser.go#L55-L91","documentation":"installParserCustomFrom copies the custom parser file into the freshly created stage directory with Copy and wraps the error. The stage directory exists at this point, so failures come from reading the source or writing the destination file.","triggerScenarios":"Copy(customParserPath, customParserDest) failing: the source custom parser file doesn't exist or is unreadable, destination stage dir not writable, or customParserName resolves to an invalid filename.","commonSituations":"Custom parser deleted/moved between the stat check and the copy; source path is a directory rather than a file; disk full; stage directory name derived from a path with odd characters.","solutions":["Confirm the custom parser source file exists and is readable: `ls -l <customParserPath>`.","Ensure the destination stage dir is writable by the test user.","Pass the file path (not a directory) as the custom parser location."],"exampleFix":"// before\ninstallParserCustom(\"./parsers/s01-parse\") // directory passed\n// after\ninstallParserCustom(\"./parsers/s01-parse/my-parser.yaml\") // file path","handlingStrategy":"validation","validationCode":"fi, err := os.Stat(customParserPath)\nif err != nil {\n\treturn fmt.Errorf(\"custom parser %s missing: %w\", customParserPath, err)\n}\nif fi.IsDir() {\n\treturn fmt.Errorf(\"custom parser path %s is a directory, pass the file\", customParserPath)\n}","typeGuard":null,"tryCatchPattern":"if err := item.InstallParserCustom(name); err != nil {\n\t// verify source file readability and stage dir writability\n\treturn err\n}","preventionTips":["Pass the parser file path, not a directory.","Ensure the source file exists before invoking install.","Keep stage dirs writable by the test user."],"tags":["hubtest","file-copy","custom-parser","filesystem"],"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"}