{"record":{"id":"c75296f629db66d1","repo":"vitessio/vitess","slug":"source-table-s-not-found-in-vschema","errorCode":null,"errorMessage":"source table %s not found in vschema","messagePattern":"source table (.+?) not found in vschema","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/wrangler/materializer.go","lineNumber":632,"sourceCode":"\t\tif err != nil {\n\t\t\treturn nil, nil, nil, err\n\t\t}\n\t}\n\tif targetVSchema.Vindexes == nil {\n\t\ttargetVSchema.Vindexes = make(map[string]*vschemapb.Vindex)\n\t}\n\tif targetVSchema.Tables == nil {\n\t\ttargetVSchema.Tables = make(map[string]*vschemapb.Table)\n\t}\n\tif existing, ok := sourceVSchema.Vindexes[vindexName]; ok {\n\t\tif !proto.Equal(existing, vindex) {\n\t\t\treturn nil, nil, nil, fmt.Errorf(\"a conflicting vindex named %s already exists in the source vschema\", vindexName)\n\t\t}\n\t}\n\tsourceVSchemaTable = sourceVSchema.Tables[sourceTableName]\n\tif sourceVSchemaTable == nil {\n\t\tif !schema.IsInternalOperationTableName(sourceTableName) {\n\t\t\treturn nil, nil, nil, fmt.Errorf(\"source table %s not found in vschema\", sourceTableName)\n\t\t}\n\t}\n\tfor _, colVindex := range sourceVSchemaTable.ColumnVindexes {\n\t\t// For a conflict, the vindex name and column should match.\n\t\tif colVindex.Name != vindexName {\n\t\t\tcontinue\n\t\t}\n\t\tcolName := colVindex.Column\n\t\tif len(colVindex.Columns) != 0 {\n\t\t\tcolName = colVindex.Columns[0]\n\t\t}\n\t\tif colName == sourceVindexColumns[0] {\n\t\t\treturn nil, nil, nil, fmt.Errorf(\"ColumnVindex for table %v already exists: %v, please remove it and try again\", sourceTableName, colName)\n\t\t}\n\t}\n\n\t// Validate against source schema\n\tsourceShards, err := wr.ts.GetServingShards(ctx, keyspace)","sourceCodeStart":614,"sourceCodeEnd":650,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/wrangler/materializer.go#L614-L650","documentation":"CreateLookupVindex requires the source table to be present in the source keyspace's vschema. When the table entry is missing (and the table is not an internal Vitess operation table), preparation aborts. The vschema entry is needed to read the table's ColumnVindexes and to attach the new lookup vindex.","triggerScenarios":"Running CreateLookupVindex for a table that exists in MySQL but has no entry in `sourceVSchema.Tables` — e.g. the keyspace is unsharded with no explicit table config, or the table name in the request doesn't match the vschema key (case or keyspace-qualified name mismatch).","commonSituations":"Newly created tables never added to the sharded vschema; typos in table names; running against an unsharded keyspace where Tables map was never populated.","solutions":["Add a table entry for the source table in the source keyspace vschema (`vtctldclient ApplyVSchema`), even if empty `{}`, then retry","Verify the table name matches exactly (case-sensitive) the key in the vschema Tables map","Confirm you are targeting the correct keyspace"],"exampleFix":"// before: table absent from vschema\n// after: add the table to the vschema JSON\n\"tables\": {\n  \"users\": {}\n}","handlingStrategy":"validation","validationCode":"vs, _ := ts.GetVSchema(ctx, keyspace)\nif vs.Tables[sourceTableName] == nil && !schema.IsInternalOperationTableName(sourceTableName) {\n    return fmt.Errorf(\"add table %s to the vschema first\", sourceTableName)\n}","typeGuard":"func tableInVSchema(vs *vschemapb.Keyspace, table string) bool {\n    return vs.Tables != nil && vs.Tables[table] != nil\n}","tryCatchPattern":"if err := createLookupVindex(...); err != nil {\n    if strings.Contains(err.Error(), \"not found in vschema\") {\n        return applyTableToVSchema(ks, table) // then retry\n    }\n    return err\n}","preventionTips":["When sharding a keyspace, register every table in the vschema, even as an empty {} entry","Verify table names case-sensitively against the vschema before running commands","Use `vtctldclient GetVSchema` to audit table entries as part of pre-flight checks"],"tags":["vitess","vschema","vindex","missing-table"],"backgroundTag":"table-missing-in-vschema","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}