golangci/golangci-lint · error
can't filter issue %#v: %w
Error message
can't filter issue %#v: %w
What it means
A per-issue filter callback (used by processors such as exclusion rules) returned an error while evaluating an issue. The processor stops and wraps the filter's error together with the offending issue for diagnosis. This is an internal-invariant error: filters are expected to evaluate without error.
Source
Thrown at pkg/result/processors/issues.go:48
retIssues = append(retIssues, issue)
}
}
return retIssues
}
func filterIssuesErr(issues []*result.Issue, filter func(issue *result.Issue) (bool, error)) ([]*result.Issue, error) {
retIssues := make([]*result.Issue, 0, len(issues))
for _, issue := range issues {
if issue.FromLinter == typeCheckName {
// don't hide typechecking errors in generated files: users expect to see why the project isn't compiling
retIssues = append(retIssues, issue)
continue
}
ok, err := filter(issue)
if err != nil {
return nil, fmt.Errorf("can't filter issue %#v: %w", issue, err)
}
if ok {
retIssues = append(retIssues, issue)
}
}
return retIssues, nil
}
func transformIssues(issues []*result.Issue, transform func(issue *result.Issue) *result.Issue) []*result.Issue {
retIssues := make([]*result.Issue, 0, len(issues))
for _, issue := range issues {
newIssue := transform(issue)
if newIssue != nil {
retIssues = append(retIssues, newIssue)
}
}View on GitHub (pinned to ed7a235d2d)
Solutions
- Read the wrapped inner error; it usually points to an invalid regex in your exclusion config
- Validate every regex in exclude-rules (text/source/path) with a regex tester or linter
- Update golangci-lint or the plugin providing the custom filter
- Temporarily remove exclusion rules one by one to identify the offending rule
Example fix
# before (.golangci.yml) exclude-rules: - path: "pkg/([unclosed" # after exclude-rules: - path: "^pkg/internal/"
Defensive patterns
Strategy: try-catch
Validate before calling
// pre-validate exclusion regexes before running
for _, rule := range cfg.ExcludeRules {
if _, err := regexp.Compile(rule.Text); err != nil {
return fmt.Errorf("invalid exclude-rule regex %q: %w", rule.Text, err)
}
} Try / catch
issues, err := processor.Process(issues)
var wrapped *fmt.WrapError
if err != nil {
if strings.Contains(err.Error(), "can't filter issue") {
log.Printf("filter failed: %v — check exclude-rules regexes", err)
}
return err
} Prevention
- Test every exclusion regex against sample issue text before committing config
- Run `golangci-lint config verify` when available
- Avoid hand-editing regex paths; use anchored, simple patterns
- Upgrade golangci-lint/plugins when filter internals change
When it happens
Trigger: A configured exclusion/preset processor (e.g. exclusion-rules with source patterns) whose regex filter fails to compile or match (invalid regexp) when applied to an issue, causing filter(issue) to return err.
Common situations: Hand-edited .golangci.yml exclude-rules with malformed regex in `text:` or `source:`; plugin-provided custom filters panicking/erroring; golangci-lint version changes altering filter expectations.
Related errors
- compile path pattern %q: %w
- failed to create linter %q: %w
- can't combine option --config and --no-config
- can't get enabled formatters: %w
- invalid path regex: %w
AI-assisted analysis of golangci/golangci-lint@ed7a235d2d (2026-09-02).
Data as JSON: /api/errors/124628e9b46ddcaf.
Report an issue: GitHub.