{"record":{"id":"3da64ba77948134a","repo":"crowdsecurity/crowdsec","slug":"failed-to-load-parser-patterns-w","errorCode":null,"errorMessage":"failed to load parser patterns: %w","messagePattern":"failed to load parser patterns: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pkg/parser/unix_parser.go","lineNumber":119,"sourceCode":"\tsort.Slice(parsers.PovfwStageFiles, func(i, j int) bool {\n\t\treturn parsers.PovfwStageFiles[i].Filename < parsers.PovfwStageFiles[j].Filename\n\t})\n\n\treturn parsers\n}\n\nfunc LoadParsers(cConfig *csconfig.Config, hub *cwhub.Hub) (*Parsers, error) {\n\tvar err error\n\n\tpatternDir := cConfig.ConfigPaths.PatternDir\n\tlog.Infof(\"Loading grok library %s\", patternDir)\n\n\tparsers := NewParsers(hub)\n\n\t/* load base regexps for two grok parsers */\n\tparsers.Ctx, err = NewUnixParserCtx(patternDir, cConfig.ConfigPaths.DataDir)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to load parser patterns: %w\", err)\n\t}\n\n\tparsers.PovfwCtx, err = NewUnixParserCtx(patternDir, cConfig.ConfigPaths.DataDir)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to load postovflw parser patterns: %w\", err)\n\t}\n\n\t/*\n\t\tLoad enrichers\n\t*/\n\tlog.Info(\"Loading enrich plugins\")\n\n\tparsers.EnricherCtx, err = Loadplugin()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to load enrich plugin: %w\", err)\n\t}\n\n\t/*","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/parser/unix_parser.go#L101-L137","documentation":"LoadParsers builds the main grok-parser context via NewUnixParserCtx, which loads the base regex pattern files (hive/hub patterns) for the parsers. If those pattern files are missing, unreadable, or malformed, parser initialization aborts and the cause is wrapped here.","triggerScenarios":"initCrowdsec -> LoadParsers calls NewUnixParserCtx(patternDir, cConfig.ConfigPaths.DataDir); it errors when the pattern directory is empty, the pattern files (e.g. crowdsecurity/*.txt from the hub) are absent, or a pattern file cannot be parsed.","commonSituations":"DataDir misconfigured in config.yaml pointing to a nonexistent path; `cscli hub update`/`install` never ran so parser patterns are missing; permission problems on the data directory.","solutions":["Check `config_paths.data_dir` in config.yaml points to the directory containing `patterns/`.","Run `cscli hub update && cscli hub install crowdsecurity/...` (or `cscli hub upgrade`) to install parser patterns.","Verify read permissions on the pattern files for the crowdsec user.","Inspect the wrapped error for the specific missing/invalid pattern file and fix or re-download it."],"exampleFix":"// before (config.yaml)\nconfig_paths:\n  data_dir: /nonexistent/data\n// after\nconfig_paths:\n  data_dir: /var/lib/crowdsec/data/","handlingStrategy":"try-catch","validationCode":"// before starting parsers, verify patterns exist\npatternFiles, err := filepath.Glob(filepath.Join(patternDir, \"*.txt\"))\nif err != nil || len(patternFiles) == 0 {\n    return fmt.Errorf(\"no parser patterns in %q; run 'cscli hub update && cscli hub install'\", patternDir)\n}","typeGuard":null,"tryCatchPattern":"parsers, err := LoadParsers(hub, cfg)\nif err != nil {\n    if strings.Contains(err.Error(), \"failed to load parser patterns\") {\n        log.Error(\"patterns missing/corrupt: run 'cscli hub update' and check data_dir\")\n    }\n    return err\n}","preventionTips":["Run `cscli hub update` / hub install after installs and upgrades so patterns exist.","Verify `config_paths.data_dir` matches the real crowdsec data directory.","After OS/user changes, re-check read permissions on the data dir."],"tags":["parser","patterns","startup","config"],"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-14T00:17:10.932Z"}