{"record":{"id":"93c8165afe98d1eb","repo":"golangci/golangci-lint","slug":"invalid-path-except-regex-w","errorCode":null,"errorMessage":"invalid path-except regex: %w","messagePattern":"invalid path-except regex: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/config/base_rule.go","lineNumber":26,"sourceCode":"\ntype BaseRule struct {\n\tLinters    []string `mapstructure:\"linters\"`\n\tPath       string   `mapstructure:\"path\"`\n\tPathExcept string   `mapstructure:\"path-except\"`\n\tText       string   `mapstructure:\"text\"`\n\tSource     string   `mapstructure:\"source\"`\n\n\t// For compatibility with exclude-use-default/include.\n\tInternalReference string `mapstructure:\"-\"`\n}\n\nfunc (b *BaseRule) Validate(minConditionsCount int) error {\n\tif err := validateOptionalRegex(b.Path); err != nil {\n\t\treturn fmt.Errorf(\"invalid path regex: %w\", err)\n\t}\n\n\tif err := validateOptionalRegex(b.PathExcept); err != nil {\n\t\treturn fmt.Errorf(\"invalid path-except regex: %w\", err)\n\t}\n\n\tif err := validateOptionalRegex(b.Text); err != nil {\n\t\treturn fmt.Errorf(\"invalid text regex: %w\", err)\n\t}\n\n\tif err := validateOptionalRegex(b.Source); err != nil {\n\t\treturn fmt.Errorf(\"invalid source regex: %w\", err)\n\t}\n\n\tif b.Path != \"\" && b.PathExcept != \"\" {\n\t\treturn errors.New(\"path and path-except should not be set at the same time\")\n\t}\n\n\tnonBlank := 0\n\tif len(b.Linters) > 0 {\n\t\tnonBlank++\n\t}","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/config/base_rule.go#L8-L44","documentation":"Validation guard in BaseRule.Validate: the 'path-except' field of an exclusion/presets rule is set but is not a valid regular expression (compile failed). The rule cannot be applied, so validation fails; the compile error is wrapped with %w.","triggerScenarios":"A `path-except` value in an exclusion/inclusion rule is not a valid Go regexp: unbalanced constructs, bad escapes, or unsupported features like backreferences or lookarounds.","commonSituations":"Writing path-except as a glob (`**/*.go`) instead of a regex; using JS-style negative lookahead; YAML double-quote escaping removing backslashes.","solutions":["Fix the `path-except` regex to valid Go RE2 syntax","Remember path-except is a regex, not a glob — convert `**/*.go` to `.*\\.go$`","Use single-quoted YAML strings to preserve backslashes","Test the pattern in a Go regex validator before adding it to config"],"exampleFix":"# before\npath-except: \"**/*_test.go\"\n# after\npath-except: '_test\\.go$'","handlingStrategy":"validation","validationCode":"func checkPathExcept(pattern string) error {\n\tif pattern == \"\" {\n\t\treturn nil\n\t}\n\tif strings.Contains(pattern, \"**\") {\n\t\treturn fmt.Errorf(\"path-except is a regex, not a glob: %q\", pattern)\n\t}\n\t_, err := regexp.Compile(pattern)\n\treturn err\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat path-except as a regex, never a glob","Test patterns with Go regexp before adding to config","Prefer single-quoted YAML scalars to preserve backslashes","Split complex patterns into path + path-except pairs"],"tags":["golangci-lint","config","regex","validation"],"backgroundTag":"invalid-regex-pattern","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}