{"record":{"id":"f1ddcbd4f6a98cbe","repo":"googleapis/mcp-toolbox","slug":"failed-to-update-logical-view-w","errorCode":null,"errorMessage":"failed to update logical view: %w","messagePattern":"failed to update logical view: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/bigtable/admin_wrappers.go","lineNumber":224,"sourceCode":"\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\n\t\tLogicalViewID: logicalViewId,\n\t\tQuery:         query,\n\t}\n\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","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/bigtable/admin_wrappers.go#L206-L242","documentation":"UpdateLogicalView wraps errors from InstanceAdmin.UpdateLogicalView, which replaces the SQL query of an existing logical view. Failures occur when the view does not exist (NotFound), the new query is invalid, or permissions are insufficient. The config must be passed by value per the bigtable SDK requirement.","triggerScenarios":"Calling UpdateLogicalView (bigtable_update_logical_view tool) when: logicalViewId does not exist in instanceId, the replacement query fails validation, caller lacks bigtable.views.update permission, or a transient RPC failure occurs.","commonSituations":"Updating a view whose name was renamed/mispelled; SQL query drift after the underlying table schema changed; IAM role changes removed update permission; passing a pointer to LogicalViewInfo causing an SDK-level error.","solutions":["Verify the logical view exists first (ListLogicalViews/MaterializedViews or GetLogicalViewInfo) to distinguish NotFound from query errors","Validate the new SQL query against current table schema","Keep passing bigtable.LogicalViewInfo by value (comment in code says 'MUST be value per bigtable SDK'); a pointer can cause SDK-side failures","Grant roles/bigtable.admin or bigtable.views.update to the service account"],"exampleFix":"// before: pointer config (SDK requires value)\nconf := &bigtable.LogicalViewInfo{LogicalViewID: id, Query: q}\ns.InstanceAdmin.UpdateLogicalView(ctx, inst, *conf)\n// after: value config as SDK requires\nconf := bigtable.LogicalViewInfo{LogicalViewID: id, Query: q}\nerr := s.InstanceAdmin.UpdateLogicalView(ctx, inst, conf)","handlingStrategy":"validation","validationCode":"// confirm the view exists and the query parses before updating\nviews, err := src.ListLogicalViews(ctx, instanceId)\nif err != nil { return err }\nif !containsViewID(views, viewId) {\n    return fmt.Errorf(\"logical view %q does not exist in %s; create it first\", 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":"res, err := src.UpdateLogicalView(ctx, instanceId, viewId, query)\nif err != nil {\n    if isNotFound(err) {\n        return src.CreateLogicalView(ctx, instanceId, viewId, query) // upsert pattern\n    }\n    return err\n}","preventionTips":["Verify the logical view exists before updating; prefer upsert (update, fall back to create on NotFound)","Pass bigtable.LogicalViewInfo by value as the SDK requires — never a pointer","Re-validate the SQL query whenever the underlying table schema changes","Keep bigtable.views.update IAM grants on the service account"],"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"}