{"record":{"id":"67634ad4852f1605","repo":"vitessio/vitess","slug":"table-s-not-found-in-vschema-for-keyspace-s","errorCode":null,"errorMessage":"table %s not found in vschema for keyspace %s","messagePattern":"table (.+?) not found in vschema for keyspace (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtctl/workflow/materializer.go","lineNumber":497,"sourceCode":"\n\treturn nil\n}\n\nfunc (mz *materializer) buildMaterializer() error {\n\tctx := mz.ctx\n\tms := mz.ms\n\tvschema, err := mz.ts.GetVSchema(ctx, ms.TargetKeyspace)\n\tif err != nil {\n\t\treturn err\n\t}\n\ttargetVSchema, err := vindexes.BuildKeyspaceSchema(vschema.Keyspace, ms.TargetKeyspace, mz.env.Parser())\n\tif err != nil {\n\t\treturn err\n\t}\n\tif targetVSchema.Keyspace.Sharded {\n\t\tfor _, ts := range ms.TableSettings {\n\t\t\tif targetVSchema.Tables[ts.TargetTable] == nil {\n\t\t\t\treturn fmt.Errorf(\"table %s not found in vschema for keyspace %s\", ts.TargetTable, ms.TargetKeyspace)\n\t\t\t}\n\t\t}\n\t}\n\tisPartial := false\n\tsourceShards, err := mz.sourceTs.GetServingShards(ctx, ms.SourceKeyspace)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(ms.SourceShards) > 0 {\n\t\tisPartial = true\n\t\tvar sourceShards2 []*topo.ShardInfo\n\t\tfor _, shard := range sourceShards {\n\t\t\tif slices.Contains(ms.SourceShards, shard.ShardName()) {\n\t\t\t\tsourceShards2 = append(sourceShards2, shard)\n\t\t\t}\n\t\t}\n\t\tsourceShards = sourceShards2\n\t}","sourceCodeStart":479,"sourceCodeEnd":515,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtctl/workflow/materializer.go#L479-L515","documentation":"buildMaterializer validates that every table in the workflow's TableSettings exists in the target keyspace's vschema. When the target keyspace is sharded, each target table must be declared in the target vschema (with a vindex) so rows can be routed. This error means a requested table is absent from the target vschema.","triggerScenarios":"createWorkflowStreams or WorkflowAddTables calls buildMaterializer with ms.TableSettings referencing a table not present in targetVSchema.Tables while targetVSchema.Keyspace.Sharded is true.","commonSituations":"Adding a table to a MoveTables workflow before loading an updated vschema on the target keyspace; typo in table name; table created in MySQL but never added to the vschema JSON; vschema applied to wrong keyspace.","solutions":["Add the table (with appropriate vindex) to the target keyspace's vschema and re-apply it (vtctl ApplyVSchema)","Correct the table name in the workflow AddTables/CreateWorkflow request","Verify the workflow targets the intended keyspace and that the vschema was applied there"],"exampleFix":"// before (target vschema missing table)\n{\"sharded\":true,\"vindexes\":{...},\"tables\":{}}\n// after\n{\"sharded\":true,\"vindexes\":{\"hash\":{\"type\":\"hash\"}},\"tables\":{\"customer\":{\"column_vindexes\":[{\"column\":\"id\",\"name\":\"hash\"}]}}}","handlingStrategy":"validation","validationCode":"vs, err := ts.GetVSchema(ctx, targetKeyspace)\nif err != nil { return err }\nfor _, t := range tables {\n    if vs.Tables[t] == nil {\n        return fmt.Errorf(\"add table %s to target vschema for %s first\", t, targetKeyspace)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := workflowAddTables(ctx, ks, wf, tables); err != nil {\n    if strings.Contains(err.Error(), \"not found in vschema\") {\n        // apply an updated vschema including the table, then retry\n    }\n    return err\n}","preventionTips":["Always ApplyVSchema on the target keyspace before creating MoveTables workflows","Keep target vschema in a checked-in file and apply it as part of workflow runbooks","Validate table names against the vschema in CI scripts before running vtctl"],"tags":["vitess","workflow","vschema","sharded-keyspace","missing-table"],"backgroundTag":"table-not-in-vschema","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}