Add AnalysisError type and wrap all analyzer error paths#4779
Merged
Conversation
shahzadhaider1
previously requested changes
Feb 28, 2026
6ef6651 to
409135f
Compare
793a1b5 to
b747fd9
Compare
b747fd9 to
0f66014
Compare
shahzadhaider1
approved these changes
Apr 3, 2026
0f66014 to
9fe25fe
Compare
Contributor
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.
amanfcp
approved these changes
Apr 10, 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.
e21487f to
9dbe823
Compare
Changes were addressed and reviewer subsequently approved. Dismissing stale change request.
MuneebUllahKhan222
pushed a commit
that referenced
this pull request
May 29, 2026
* Add AnalysisError type and AnalysisErrorInfo interface 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. * Wrap errors in simple API analyzers with AnalysisError 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". * Wrap errors in remaining analyzers with AnalysisError (Batches B-E) 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) * Use Type().String() and constants for NewAnalysisError calls 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.). * Omit empty resource parenthetical from AnalysisError messages 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. * Wrap no-data error path in GitHub analyzer with AnalysisError
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 error-return paths across many analyzers; behavior should be equivalent but changes the concrete error type/message, which could affect downstream error handling or assertions.
Overview
Introduces a new structured
AnalysisError(withAnalysisErrorInfointerface) plus sharedOperation*andService*constants so analyzer failures can carry consistent metadata and stillUnwrap()to the original error.Updates many analyzers to wrap both missing credential validation errors and permission/API/DB analysis failures with
analyzers.NewAnalysisError(...)instead of returning raw errors, standardizing how failures are reported and stored.Reviewed by Cursor Bugbot for commit 9dbe823. Bugbot is set up for automated code reviews on this repo. Configure here.