{"record":{"id":"5b89d145537c0cfe","repo":"golangci/golangci-lint","slug":"forbidigo-linter-failed-on-file-q-w","errorCode":null,"errorMessage":"forbidigo linter failed on file %q: %w","messagePattern":"forbidigo linter failed on file %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/golinters/forbidigo/forbidigo.go","lineNumber":73,"sourceCode":"\n\tforbid, err := forbidigo.NewLinter(patterns, options...)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create linter %q: %w\", linterName, err)\n\t}\n\n\tfor _, file := range pass.Files {\n\t\trunConfig := forbidigo.RunConfig{\n\t\t\tFset:     pass.Fset,\n\t\t\tDebugLog: logutils.Debug(logutils.DebugKeyForbidigo),\n\t\t}\n\n\t\tif settings.AnalyzeTypes {\n\t\t\trunConfig.TypesInfo = pass.TypesInfo\n\t\t}\n\n\t\thints, err := forbid.RunWithConfig(runConfig, file)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"forbidigo linter failed on file %q: %w\", file.Name.String(), err)\n\t\t}\n\n\t\tfor _, hint := range hints {\n\t\t\tpass.Report(analysis.Diagnostic{\n\t\t\t\tPos:     hint.Pos(),\n\t\t\t\tMessage: hint.Details(),\n\t\t\t})\n\t\t}\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":55,"sourceCodeEnd":86,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/golinters/forbidigo/forbidigo.go#L55-L86","documentation":"After successfully creating the forbidigo linter, runForbidigo runs it per AST file with RunWithConfig. If forbidigo itself errors while matching a file, the error is wrapped as 'forbidigo linter failed on file %q'. This is an internal failure of the linter on a specific file, not a rule violation.","triggerScenarios":"forbid.RunWithConfig(runConfig, file) returns an error for one file — e.g. with settings.analyze-types: true, type information is missing or inconsistent in runConfig, or the file node/config combination is invalid.","commonSituations":"Enabling analyze-types on a run where TypesInfo wasn't fully populated (generated/cgo files, malformed packages), or forbidigo version mismatches where RunConfig fields differ from what golangci-lint passes.","solutions":["Disable settings.forbidigo.analyze-types and re-run to isolate the failure","Fix the package so type checking completes (resolve cgo/build-tag/generated-file issues for the named file)","Upgrade or pin golangci-lint so golangci-lint's forbidigo wrapper matches the bundled forbidigo API","Exclude the problematic file via issues.exclude-files/exclude-dirs and report upstream if it persists"],"exampleFix":"# before\nlinters:\n  settings:\n    forbidigo:\n      analyze-types: true\n# after\nlinters:\n  settings:\n    forbidigo:\n      analyze-types: false","handlingStrategy":"try-catch","validationCode":"// If using analyze-types, ensure packages type-check first:\nfor _, pkg := range pkgs {\n    for _, e := range pkg.Errors {\n        return fmt.Errorf(\"package %s must type-check before forbidigo analyze-types: %v\", pkg.PkgPath, e)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := golangci.Run(); err != nil {\n    if strings.Contains(err.Error(), \"forbidigo linter failed on file\") {\n        file := extractQuoted(err) // e.g. via regexp \"on file \\\"([^\\\"]+)\\\"\"\n        log.Warnf(\"forbidigo failed on %s; retry with analyze-types: false or exclude the file\", file)\n        return retryWithoutAnalyzeTypes()\n    }\n    return err\n}","preventionTips":["Only enable analyze-types when the whole package type-checks cleanly","Exclude cgo/generated files that break type info","Pin golangci-lint so forbidigo wrapper and library versions match"],"tags":["golangci-lint","forbidigo","type-checking"],"backgroundTag":"linter-run-failed-on-file","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}