{"record":{"id":"f2e9e65fe85bd80d","repo":"golangci/golangci-lint","slug":"can-t-compile-regexp-q-w","errorCode":null,"errorMessage":"can't compile regexp %q: %w","messagePattern":"can't compile regexp %q: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/result/processors/exclusion_paths.go","lineNumber":35,"sourceCode":"\tpathExceptPatterns []*regexp.Regexp\n\n\twarnUnused                bool\n\texcludedPathCounter       map[*regexp.Regexp]int\n\texcludedPathExceptCounter map[*regexp.Regexp]int\n\n\tlog logutils.Log\n}\n\nfunc NewExclusionPaths(log logutils.Log, cfg *config.LinterExclusions) (*ExclusionPaths, error) {\n\texcludedPathCounter := make(map[*regexp.Regexp]int)\n\n\tvar pathPatterns []*regexp.Regexp\n\tfor _, p := range cfg.Paths {\n\t\tp = fsutils.NormalizePathInRegex(p)\n\n\t\tpatternRe, err := regexp.Compile(p)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"can't compile regexp %q: %w\", p, err)\n\t\t}\n\n\t\tpathPatterns = append(pathPatterns, patternRe)\n\t\texcludedPathCounter[patternRe] = 0\n\t}\n\n\texcludedPathExceptCounter := make(map[*regexp.Regexp]int)\n\n\tvar pathExceptPatterns []*regexp.Regexp\n\tfor _, p := range cfg.PathsExcept {\n\t\tp = fsutils.NormalizePathInRegex(p)\n\n\t\tpatternRe, err := regexp.Compile(p)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"can't compile regexp %q: %w\", p, err)\n\t\t}\n\n\t\tpathExceptPatterns = append(pathExceptPatterns, patternRe)","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/result/processors/exclusion_paths.go#L17-L53","documentation":"NewExclusionPaths compiles each path exclusion pattern from the config into a regular expression. A pattern that is not valid Go regexp syntax fails compilation and produces this error naming the offending pattern. This is a startup/config error: golangci-lint cannot build its issue exclusion pipeline with an invalid regex.","triggerScenarios":"NewExclusionPaths is called (by NewRunner or tests) with cfg.Paths containing a string that regexp.Compile rejects — unbalanced parentheses, stray '*+', invalid escape like '\\\\', unterminated character class.","commonSituations":"Hand-written .golangci.yml exclusion patterns with unescaped regex metacharacters (e.g. 'vendor(*') ; copying file globs (paths like 'src/**/*.go') into regex-only settings; Windows-style backslash separators in patterns.","solutions":["Fix the regex syntax for the reported pattern (test it with a Go regexp playground or go test)","Escape metacharacters, e.g. use \\. for a literal dot; use forward slashes","Replace glob-style patterns with regex equivalents (e.g. '^src/.*/.*\\.go$')","Validate config before CI with a quick `golangci-lint run` locally"],"exampleFix":"# before\nissues:\n  exclude-paths:\n    - vendor\\pkg\n    - gen(.*\n# after\nissues:\n  exclude-paths:\n    - vendor/pkg\n    - ^gen/.*$","handlingStrategy":"validation","validationCode":"// Go: compile every exclusion pattern before writing it into config\nfor _, p := range cfg.Paths {\n    if _, err := regexp.Compile(fsutils.NormalizePathInRegex(p)); err != nil {\n        log.Fatalf(\"invalid exclude-paths pattern %q: %v\", p, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"ep, err := processors.NewExclusionPaths(cfg)\nif err != nil {\n    if strings.Contains(err.Error(), \"can't compile regexp\") {\n        log.Fatalf(\"fix your exclusion pattern: %v\", err)\n    }\n    return err\n}","preventionTips":["Test each pattern with a RE2-compatible playground before adding it","Remember exclude paths are regexes, not globs — escape dots and use .*","Avoid Windows backslashes; use forward slashes"],"tags":["regex","config","golangci-lint"],"backgroundTag":"invalid-regex-pattern","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}