Add AnalysisError type and wrap all analyzer error paths#4779
Open
johnelliott wants to merge 6 commits intomainfrom
Open
Add AnalysisError type and wrap all analyzer error paths#4779johnelliott wants to merge 6 commits intomainfrom
johnelliott wants to merge 6 commits intomainfrom
Conversation
shahzadhaider1
requested changes
Feb 28, 2026
6ef6651 to
409135f
Compare
793a1b5 to
b747fd9
Compare
b747fd9 to
0f66014
Compare
shahzadhaider1
approved these changes
Apr 3, 2026
Introduce a shared error type that provides structured metadata (analyzer type, operation, service, resource) for analysis failures. This allows the scanner to extract context from errors without depending on concrete types.
Batch A: Airbrake, Anthropic, Asana, DigitalOcean, DockerHub, ElevenLabs, Fastly, Groq, HuggingFace, Mailchimp, Mailgun, Mux, Netlify, Ngrok, Notion, OpenAI, Opsgenie, Posthog, Postman, Sendgrid, Sourcegraph. Wraps credential validation errors with operation "validate_credentials" and AnalyzePermissions errors with operation "analyze_permissions".
Batch B (OAuth/multi-credential): airtableoauth, airtablepat, datadog, dropbox, figma, launchdarkly, plaid Batch C (Complex): bitbucket, databricks, github, gitlab, jira, monday, planetscale, shopify, slack, square, stripe, twilio Batch D (Database): mysql, postgres (service: Database) Batch E (PrivateKey): privatekey (service: crypto)
Address PR feedback: replace hardcoded analyzer type strings with a.Type().String() and replace raw operation/service strings with package-level constants (OperationValidateCredentials, OperationAnalyzePermissions, ServiceAPI, ServiceConfig, etc.).
Conditionally include "(resource: ...)" only when non-empty, avoiding cluttered messages like "... (resource: ): ..." that appear for the majority of analyzers that don't set a resource.
0f66014 to
9fe25fe
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 9fe25fe. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What this does
Adds a shared error type so analyzer failures carry structured metadata (analyzer type, operation, service). Currently only GCP errors have this; the other 44 analyzers return bare
errors.Newthat get stored as "unknown" in the database.How to review
Read one file, skip the other 44. There are only 2 things to look at:
1. The new error type (entire abstraction)
pkg/analyzer/analyzers/errors.go-- new file:2. The pattern every analyzer follows
Every analyzer diff looks like this (Airbrake shown):
The original error is wrapped, not replaced (
Unwrap()preserves the chain). Analyzer type is derived dynamically viaa.Type().String(). Two operation constants are used:OperationValidateCredentialsfor bad input,OperationAnalyzePermissionsfor API/DB failures.All 44 analyzer files are this same 1-3 line change. You can spot-check a few and skip the rest.
Part of a cross-repo change
errors.As()Test plan
go test ./pkg/analyzer/analyzers/...(includeserrors_test.go)go build ./pkg/analyzer/analyzers/...Note
Medium Risk
Touches many analyzers’
Analyzeerror paths; while changes are mechanical, they alter the error types and messages that downstream consumers may depend on.Overview
Adds a new
analyzers.AnalysisError(andAnalysisErrorInfointerface) plus sharedoperation/serviceconstants so analyzer failures can be reported with structured metadata while preserving the original error viaUnwrap().Updates a broad set of analyzers to wrap all
Analyze-time failures (missing/invalid credential fields and API/DB/crypto permission checks) usinganalyzers.NewAnalysisError(...)instead of returning raw errors, and includes unit tests for the new error type.Reviewed by Cursor Bugbot for commit e21487f. Bugbot is set up for automated code reviews on this repo. Configure here.