Skip to content

feat(googlecloud): report missing IAM roles on permission errors and preserve client error types - #1190

Merged
kyasbal merged 2 commits into
GoogleCloudPlatform:mainfrom
kyasbal:push-ltzzszwkszxw
Oct 29, 2026
Merged

kyasbal merged 2 commits into
GoogleCloudPlatform:mainfrom
kyasbal:push-ltzzszwkszxw

Conversation

@kyasbal

@kyasbal kyasbal commented Oct 29, 2026

Copy link
Copy Markdown
Member

Fixes #1121

Summary

Google Cloud API permission errors (codes.PermissionDenied and HTTP 403 responses) previously surfaced raw RPC descriptions without identifying which IAM role was needed on which project or resource. This change enriches permission-denied errors at the Google Cloud API boundary with the denied permission, target resource or quota project, and recommended IAM role(s) (roles/logging.viewer, roles/logging.privateLogViewer, roles/logging.viewAccessor, roles/monitoring.viewer, roles/cloudasset.viewer, roles/compute.viewer, roles/container.viewer, and roles/serviceusage.serviceUsageConsumer) while preserving the underlying error chain via Unwrap() and leaving non-IAM 403 reasons (SERVICE_DISABLED, BILLING_DISABLED, ACCESS_TOKEN_SCOPE_INSUFFICIENT) untouched. Because both MCP tool outputs and Web UI banners render the error string directly, the actionable role guidance appears across all inspection and autocomplete surfaces without MCP-specific error codes.

In addition, structured log estimation now joins Cloud Logging and Cloud Monitoring client initialization errors with errors.Join and %w instead of formatting them with %v, ensuring callers retain the underlying authentication and client error types via errors.As.

UI / Output Changes

# Inspection `2026-09-24-0130-a1b2`

Status: ERROR.

| Task | Error |
| --- | --- |
| Fetch Kubernetes Audit Logs | missing permission logging.logEntries.list on projects/my-gcp-project; grant roles/logging.viewer or roles/logging.privateLogViewer to the active credentials: rpc error: code = PermissionDenied desc = Permission 'logging.logEntries.list' denied on resource (or it may not exist). |
@kyasbal kyasbal added type:feature New feature or request area:backend-core Core backend frameworks, DAG task runner, and server API area:backend-parser Log parsers and log timeline mapper tasks labels Oct 29, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new error wrapping utility, WrapPermissionDenied, in pkg/api/googlecloud/permission_error.go to annotate Google Cloud permission errors with missing permissions and recommended IAM roles. Various log, metric, and asset fetchers are updated to wrap their permission-denied errors using this utility. The review feedback suggests that the custom permissionDeniedError struct should explicitly implement GRPCStatus() *status.Status and HTTPCode() int methods to ensure seamless integration with standard gRPC and HTTP error-handling utilities.

Comment thread pkg/api/googlecloud/permission_error.go Resolved
@kyasbal
kyasbal enabled auto-merge October 29, 2026 02:55
@kyasbal
kyasbal added this pull request to the merge queue Oct 29, 2026
Merged via the queue into GoogleCloudPlatform:main with commit 99e2a3a Oct 29, 2026
17 checks passed
@kyasbal
kyasbal deleted the push-ltzzszwkszxw branch October 29, 2026 03:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:backend-core Core backend frameworks, DAG task runner, and server API area:backend-parser Log parsers and log timeline mapper tasks type:feature New feature or request

1 participant