{"record":{"id":"ed9409be6202908b","repo":"googleapis/mcp-toolbox","slug":"failed-to-create-table-w","errorCode":null,"errorMessage":"failed to create table: %w","messagePattern":"failed to create table: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/bigtable/admin_wrappers.go","lineNumber":142,"sourceCode":"\terr := s.InstanceAdmin.DeleteCluster(ctx, instanceId, clusterId)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to delete cluster: %w\", err)\n\t}\n\treturn map[string]string{\"status\": \"cluster deleted successfully\"}, nil\n}\n\nfunc (s *Source) GetTable(ctx context.Context, tableId string) (any, error) {\n\ttable, err := s.Admin.TableInfo(ctx, tableId)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get table: %w\", err)\n\t}\n\treturn table, nil\n}\n\nfunc (s *Source) CreateTable(ctx context.Context, tableId, columnFamily string) (any, error) {\n\terr := s.Admin.CreateTable(ctx, tableId)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create table: %w\", err)\n\t}\n\tif columnFamily != \"\" {\n\t\tif err := s.Admin.CreateColumnFamily(ctx, tableId, columnFamily); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to create column family: %w\", err)\n\t\t}\n\t}\n\treturn map[string]string{\"status\": \"table created successfully\"}, nil\n}\n\nfunc (s *Source) DeleteTable(ctx context.Context, tableId string) (any, error) {\n\terr := s.Admin.DeleteTable(ctx, tableId)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to delete table: %w\", err)\n\t}\n\treturn map[string]string{\"status\": \"table deleted successfully\"}, nil\n}\n\nfunc (s *Source) ListTables(ctx context.Context) (any, error) {","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/bigtable/admin_wrappers.go#L124-L160","documentation":"This error wraps failures from the Bigtable Admin client's CreateTable call in Source.CreateTable. The library wraps the underlying error with fmt.Errorf(\"failed to create table: %w\", err) while keeping the original gRPC error chain intact. Note this fires before the optional column-family step; a bad columnFamily produces the separate 'failed to create column family' error instead.","triggerScenarios":"Calling the bigtable create_table tool where s.Admin.CreateTable(ctx, tableId) errors: the table already exists (ALREADY_EXISTS), invalid table ID characters, missing bigtable.tables.create permission, or a transient gRPC failure.","commonSituations":"Re-running a script that already created the table; invalid IDs (Bigtable IDs must match [_a-zA-Z0-9][-_.a-zA-Z0-9]*); service account lacking Bigtable Admin; emulator not running during local dev.","solutions":["Check if the table already exists (list_tables) and skip creation or use a new ID; handle gRPC ALREADY_EXISTS explicitly.","Validate tableId against Bigtable naming rules before calling.","Grant the caller roles/bigtable.admin (bigtable.tables.create).","Retry transient gRPC errors with backoff; inspect status.Code(err) to pick the right branch."],"exampleFix":"// before\nerr := s.Admin.CreateTable(ctx, tableId)\n// after: tolerate idempotent re-runs\nif code := status.Code(err); code != codes.AlreadyExists {\n    return nil, fmt.Errorf(\"failed to create table: %w\", err)\n}","handlingStrategy":"validation","validationCode":"// Go: pre-flight checks before CreateTable\nif !regexp.MustCompile(`^[_a-zA-Z0-9][-_.a-zA-Z0-9]*$`).MatchString(tableId) {\n    return fmt.Errorf(\"invalid table id: %q\", tableId)\n}\nexisting, _ := admin.Tables(ctx)\nfor _, t := range existing {\n    if t == tableId {\n        return nil // already created; skip\n    }\n}","typeGuard":"func isAlreadyExists(err error) bool {\n    return status.Code(err) == codes.AlreadyExists\n}","tryCatchPattern":"if err := src.CreateTable(ctx, tableId, cf); err != nil {\n    if status.Code(err) == codes.AlreadyExists {\n        return nil // idempotent re-run\n    }\n    return fmt.Errorf(\"create table: %w\", err)\n}","preventionTips":["Check table existence before creation in scripts that may re-run.","Validate table IDs against Bigtable's naming pattern client-side.","Handle codes.AlreadyExists explicitly instead of failing.","Ensure create permissions (bigtable.tables.create) on the service account."],"tags":["gcp","bigtable","grpc","iam","admin-api"],"backgroundTag":"gcp-grpc-admin-operation-failed","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"}