{"record":{"id":"4981eb13b8fccd58","repo":"googleapis/mcp-toolbox","slug":"failed-to-list-materialized-views-w","errorCode":null,"errorMessage":"failed to list materialized views: %w","messagePattern":"failed to list materialized views: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/bigtable/admin_wrappers.go","lineNumber":200,"sourceCode":"\tview, err := s.InstanceAdmin.LogicalViewInfo(ctx, instanceId, logicalViewId)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get logical view: %w\", err)\n\t}\n\treturn view, nil\n}\n\nfunc (s *Source) ListLogicalViews(ctx context.Context, instanceId string) (any, error) {\n\tviews, err := s.InstanceAdmin.LogicalViews(ctx, instanceId)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to list logical views: %w\", err)\n\t}\n\treturn views, nil\n}\n\nfunc (s *Source) ListMaterializedViews(ctx context.Context, instanceId string) (any, error) {\n\tviews, err := s.InstanceAdmin.MaterializedViews(ctx, instanceId)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to list materialized views: %w\", err)\n\t}\n\treturn views, nil\n}\n\nfunc (s *Source) CreateLogicalView(ctx context.Context, instanceId, logicalViewId, query string) (any, error) {\n\tconf := &bigtable.LogicalViewInfo{\n\t\tLogicalViewID: logicalViewId,\n\t\tQuery:         query,\n\t}\n\terr := s.InstanceAdmin.CreateLogicalView(ctx, instanceId, conf)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create logical view: %w\", err)\n\t}\n\treturn map[string]string{\"status\": \"logical view created successfully\"}, nil\n}\n\nfunc (s *Source) UpdateLogicalView(ctx context.Context, instanceId, logicalViewId, query string) (any, error) {\n\tconf := bigtable.LogicalViewInfo{ // MUST be value per bigtable SDK","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/bigtable/admin_wrappers.go#L182-L218","documentation":"ListMaterializedViews wraps any error returned by the Cloud Bigtable InstanceAdmin client's MaterializedViews() call with context. It means the admin RPC listing materialized views for the instance failed (auth, permissions, network, or unknown instance). The original gRPC/API error is preserved via %w for errors.Is/As inspection.","triggerScenarios":"Calling ListMaterializedViews (bigtable_list_materialized_views tool) when: the project/instance ID does not exist, the credentials lack bigtable.tables.list / materialized view list permission, ADC are missing, or a transient gRPC/network failure occurs during the InstanceAdmin.MaterializedViews RPC.","commonSituations":"Typo'd instance ID in tool parameters; service account without the Bigtable Admin role; running locally without GOOGLE_APPLICATION_CREDENTIALS; regional outages or timeouts; listing views on an instance in a different project than configured in the source config.","solutions":["Unwrap the wrapped error with errors.As(*googleapi.Error) or status.Code to see the underlying gRPC status and address its cause","Verify the instance ID and project in the toolbox config match an existing Bigtable instance (gcloud bigtable instances list)","Grant the caller service account roles/bigtable.admin or at minimum bigtable.tables.get/list on the instance","Ensure Application Default Credentials are set (GOOGLE_APPLICATION_CREDENTIALS or gcloud auth application-default login)","Retry on transient codes (Unavailable, DeadlineExceeded)"],"exampleFix":"// before: opaque listing failure\nviews, err := s.InstanceAdmin.MaterializedViews(ctx, instanceId)\nif err != nil { return nil, fmt.Errorf(\"failed to list materialized views: %w\", err) }\n// after: surface status code for actionable handling\nviews, err := s.InstanceAdmin.MaterializedViews(ctx, instanceId)\nif err != nil {\n    if st, ok := status.FromError(err); ok && st.Code() == codes.NotFound {\n        return nil, fmt.Errorf(\"instance %q not found: %w\", instanceId, err)\n    }\n    return nil, fmt.Errorf(\"failed to list materialized views: %w\", err)\n}","handlingStrategy":"retry","validationCode":"// pre-flight: confirm instance is reachable before calling the tool\nimport \"cloud.google.com/go/bigtable\"\nadmin, err := bigtable.NewInstanceAdminClient(ctx, project)\nif err != nil { return err }\ninstances, err := admin.Instances(ctx)\nfor _, i := range instances { if i.Name == instanceId { return nil } }\nreturn fmt.Errorf(\"instance %q not found in project %s\", instanceId, project)","typeGuard":"func isNotFound(err error) bool {\n    st, ok := status.FromError(errors.Unwrap(err))\n    return ok && st.Code() == codes.NotFound\n}","tryCatchPattern":"views, err := src.ListMaterializedViews(ctx, instanceId)\nif err != nil {\n    if isNotFound(err) {\n        return nil, fmt.Errorf(\"instance %q not found\", instanceId)\n    }\n    if status.Code(err) == codes.Unavailable {\n        // retry with backoff\n    }\n    return err\n}","preventionTips":["Validate instanceId against gcloud bigtable instances list before invoking the tool","Attach roles/bigtable.admin or viewer to the service account used by the toolbox","Always configure credentials (GOOGLE_APPLICATION_CREDENTIALS) before startup","Inspect the wrapped error with errors.Unwrap/status.Code instead of treating it as opaque"],"tags":["gcp","bigtable","admin-api","permissions"],"backgroundTag":"gcp-api-error","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}