{"record":{"id":"f3b31089a022c405","repo":"googleapis/mcp-toolbox","slug":"failed-to-get-materialized-view-w","errorCode":null,"errorMessage":"failed to get materialized view: %w","messagePattern":"failed to get materialized view: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/bigtable/admin_wrappers.go","lineNumber":240,"sourceCode":"\terr := s.InstanceAdmin.UpdateLogicalView(ctx, instanceId, conf)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to update logical view: %w\", err)\n\t}\n\treturn map[string]string{\"status\": \"logical view updated successfully\"}, nil\n}\n\nfunc (s *Source) DeleteLogicalView(ctx context.Context, instanceId, logicalViewId string) (any, error) {\n\terr := s.InstanceAdmin.DeleteLogicalView(ctx, instanceId, logicalViewId)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to delete logical view: %w\", err)\n\t}\n\treturn map[string]string{\"status\": \"logical view deleted successfully\"}, nil\n}\n\nfunc (s *Source) GetMaterializedView(ctx context.Context, instanceId, materializedViewId string) (any, error) {\n\tview, err := s.InstanceAdmin.MaterializedViewInfo(ctx, instanceId, materializedViewId)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get materialized view: %w\", err)\n\t}\n\treturn view, nil\n}\n\nfunc (s *Source) CreateMaterializedView(ctx context.Context, instanceId, materializedViewId, query string) (any, error) {\n\tconf := &bigtable.MaterializedViewInfo{\n\t\tMaterializedViewID: materializedViewId,\n\t\tQuery:              query,\n\t}\n\terr := s.InstanceAdmin.CreateMaterializedView(ctx, instanceId, conf)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create materialized view: %w\", err)\n\t}\n\treturn map[string]string{\"status\": \"materialized view created successfully\"}, nil\n}\n\nfunc (s *Source) UpdateMaterializedView(ctx context.Context, instanceId, materializedViewId, query string) (any, error) {\n\tconf := bigtable.MaterializedViewInfo{ // MUST be value per bigtable SDK","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/bigtable/admin_wrappers.go#L222-L258","documentation":"GetMaterializedView wraps errors from InstanceAdmin.MaterializedViewInfo, which fetches details of one materialized view. Failures occur when the view or instance does not exist, permissions are missing, or a transient RPC failure happens. The wrapped error retains the original cause for errors.Is/As checks.","triggerScenarios":"Calling GetMaterializedView (bigtable_get_materialized_view tool) when: materializedViewId does not exist under instanceId, the instanceId is wrong, the caller lacks bigtable read permissions, or the admin RPC times out.","commonSituations":"Fetching a view after it was dropped by another process; confusing logical-view IDs with materialized-view IDs; service account missing the Bigtable Viewer/Admin role; project misconfiguration in the source config.","solutions":["Unwrap with status.FromError and handle codes.NotFound by listing available views first","Verify instanceId/project configuration and that the ID is a materialized view (not a logical view)","Grant roles/bigtable.viewer or roles/bigtable.admin to the caller's service account","Retry on transient gRPC codes (Unavailable, DeadlineExceeded)"],"exampleFix":"// before: raw NotFound bubbles to the LLM\nview, err := s.InstanceAdmin.MaterializedViewInfo(ctx, instanceId, id)\nif err != nil { return nil, fmt.Errorf(\"failed to get materialized view: %w\", err) }\n// after: friendlier NotFound handling\nview, err := s.InstanceAdmin.MaterializedViewInfo(ctx, instanceId, id)\nif err != nil {\n    if st, ok := status.FromError(err); ok && st.Code() == codes.NotFound {\n        return nil, fmt.Errorf(\"materialized view %q not found in instance %q\", id, instanceId)\n    }\n    return nil, fmt.Errorf(\"failed to get materialized view: %w\", err)\n}","handlingStrategy":"type-guard","validationCode":"views, err := src.ListMaterializedViews(ctx, instanceId)\nif err != nil { return err }\nif !containsMaterializedViewID(views, viewId) {\n    return fmt.Errorf(\"materialized view %q not found in %s\", viewId, instanceId)\n}","typeGuard":"func isNotFound(err error) bool {\n    st, ok := status.FromError(errors.Unwrap(err))\n    return ok && st.Code() == codes.NotFound\n}","tryCatchPattern":"view, err := src.GetMaterializedView(ctx, instanceId, viewId)\nif err != nil {\n    if isNotFound(err) {\n        return nil, fmt.Errorf(\"materialized view %q not found\", viewId)\n    }\n    return err\n}","preventionTips":["List materialized views first when the ID may be stale","Don't confuse logical-view IDs with materialized-view IDs","Grant roles/bigtable.viewer at minimum for read operations","Check project/instance configuration if NotFound errors appear unexpectedly"],"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"}