{"record":{"id":"e96b91ed47e335a2","repo":"golangci/golangci-lint","slug":"compile-path-pattern-q-w","errorCode":null,"errorMessage":"compile path pattern %q: %w","messagePattern":"compile path pattern %q: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/goformat/runner.go","lineNumber":248,"sourceCode":"\tabsBasePath, err := filepath.Abs(basePath)\n\tif err != nil {\n\t\treturn RunnerOptions{}, err\n\t}\n\n\topts := RunnerOptions{\n\t\tbasePath:            absBasePath,\n\t\tgenerated:           cfg.Formatters.Exclusions.Generated,\n\t\tdiff:                diff || diffColored,\n\t\tcolors:              diffColored,\n\t\tstdin:               stdin,\n\t\texcludedPathCounter: make(map[*regexp.Regexp]int),\n\t\twarnUnused:          cfg.Formatters.Exclusions.WarnUnused,\n\t}\n\n\tfor _, pattern := range cfg.Formatters.Exclusions.Paths {\n\t\texp, err := regexp.Compile(fsutils.NormalizePathInRegex(pattern))\n\t\tif err != nil {\n\t\t\treturn RunnerOptions{}, fmt.Errorf(\"compile path pattern %q: %w\", pattern, err)\n\t\t}\n\n\t\topts.patterns = append(opts.patterns, exp)\n\t\topts.excludedPathCounter[exp] = 0\n\t}\n\n\treturn opts, nil\n}\n\nfunc (o RunnerOptions) MatchAnyPattern(path string) (bool, error) {\n\tif len(o.patterns) == 0 {\n\t\treturn false, nil\n\t}\n\n\tabs, err := filepath.Abs(path)\n\tif err != nil {\n\t\treturn false, err\n\t}","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/goformat/runner.go#L230-L266","documentation":"Each path pattern under formatters.exclusions.paths is normalized and compiled as a regular expression; an invalid regex aborts runner-options construction with this wrap. golangci-lint treats formatter exclusion patterns as regexes, so syntax errors are caught eagerly at startup.","triggerScenarios":"NewRunnerOptions iterates cfg.Formatters.Exclusions.Paths and regexp.Compile fails for one of the configured patterns (e.g. unbalanced `(`, stray `*`, invalid escape).","commonSituations":"Hand-written exclusion regex in .golangci.yml with escaping mistakes (Windows backslashes not escaped); patterns copied from glob-style configs (e.g. `src/**` instead of regex).","solutions":["Fix the regex in formatters.exclusions.paths; test with `go` regexp (RE2) semantics","Escape backslashes: use `\\\\` on Windows paths, or prefer forward slashes","Convert glob-style patterns (`**`) to regex equivalents","Validate quickly with `go run` / a RE2 playground before editing config"],"exampleFix":"# before\nformatters:\n  exclusions:\n    paths:\n      - (gen|unbalanced\n# after\nformatters:\n  exclusions:\n    paths:\n      - (gen|vendor)/.*","handlingStrategy":"validation","validationCode":"// validate exclusion patterns are valid RE2 before use\nfor _, p := range patterns {\n    if _, err := regexp.Compile(p); err != nil {\n        return fmt.Errorf(\"invalid exclusion pattern %q: %w\", p, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"// catch and point at the offending config key\nif _, err := NewRunnerOptions(cfg, false, false, false); err != nil {\n    var reErr error\n    if strings.Contains(err.Error(), \"compile path pattern\") {\n        reErr = err // fix formatters.exclusions.paths\n    }\n}","preventionTips":["Test regexes in .golangci.yml with Go RE2 semantics","Escape Windows backslashes or use forward slashes","Never paste glob (`**`) patterns where regex is expected"],"tags":["golangci-lint","configuration","regex"],"backgroundTag":"invalid-regex-pattern","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}