{"record":{"id":"de536b684701ebb8","repo":"vitessio/vitess","slug":"no-sharded-vschema-was-provided-so-you-will-need","errorCode":null,"errorMessage":"no sharded vschema was provided, so you will need to update the vschema of the target manually for the moved tables","messagePattern":"no sharded vschema was provided, so you will need to update the vschema of the target manually for the moved tables","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtctl/workflow/traffic_switcher.go","lineNumber":412,"sourceCode":"\tif err != nil {\n\t\treturn err\n\t}\n\tif vschema == nil {\n\t\treturn fmt.Errorf(\"no vschema found for keyspace %s\", keyspace)\n\t}\n\tif vschema.Tables == nil {\n\t\tvschema.Tables = make(map[string]*vschemapb.Table)\n\t}\n\tif strings.HasPrefix(tableSpecs, \"{\") { // user defined the vschema snippet, typically for a sharded target\n\t\twrap := fmt.Sprintf(`{\"tables\": %s}`, tableSpecs)\n\t\tks := &vschemapb.Keyspace{}\n\t\tif err := json2.UnmarshalPB([]byte(wrap), ks); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tmaps.Copy(vschema.Tables, ks.Tables)\n\t} else {\n\t\tif vschema.Sharded {\n\t\t\treturn errors.New(\"no sharded vschema was provided, so you will need to update the vschema of the target manually for the moved tables\")\n\t\t}\n\t\tfor _, table := range ts.tables {\n\t\t\tvschema.Tables[table] = &vschemapb.Table{}\n\t\t}\n\t}\n\treturn ts.TopoServer().SaveVSchema(ctx, vschema)\n}\n\nfunc (ts *trafficSwitcher) deleteRoutingRules(ctx context.Context) error {\n\trules, err := topotools.GetRoutingRules(ctx, ts.TopoServer())\n\tif err != nil {\n\t\treturn err\n\t}\n\tfor _, table := range ts.Tables() {\n\t\tdelete(rules, table)\n\t\tdelete(rules, table+\"@replica\")\n\t\tdelete(rules, table+\"@rdonly\")\n\t\tdelete(rules, ts.TargetKeyspaceName()+\".\"+table)","sourceCodeStart":394,"sourceCodeEnd":430,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtctl/workflow/traffic_switcher.go#L394-L430","documentation":"When updating the target keyspace's vschema after a traffic switch, the code can only merge the moved tables' entries if a source (sharded) vschema was provided. If no vschema was supplied but the target vschema is sharded, the tables cannot be safely registered, so it returns this error telling the user to update the target vschema manually.","triggerScenarios":"Calling the SwitchReads/SwitchWrites path (vindex copying code in traffic_switcher.go around line 412) during a MoveTables cutover where the target vschema has Sharded=true and no source vschema document was fetched/provided.","commonSituations":"Target keyspace uses sharded vindexes but the operator never set up the source vschema context, or a cross-keyspace move where the tool cannot fetch the sharded source vschema (e.g. topoSrv vschema missing).","solutions":["Manually add the moved tables' vindex definitions to the target keyspace vschema (`vtctldclient ApplyVSchema`).","Ensure the source keyspace has a valid sharded vschema in the topo before switching traffic so the tool can copy it.","If the target should be unsharded, correct the target vschema's sharded flag before the cutover."],"exampleFix":"// before\ntopo save vschema customer: {\"sharded\": true} // no tables -> error during switch\n// after\nvtctldclient ApplyVSchema --vschema '{\"sharded\":true,\"tables\":{\"sales\":{\"column_vindexes\":[...],\"columns\":[]}}}' customer","handlingStrategy":"validation","validationCode":"vs, err := ts.TopoServer().GetVSchema(ctx, targetKeyspace)\nif err != nil { return err }\nif vs.Sharded && sourceVSchema == nil {\n    return errors.New(\"apply the target vschema manually: no sharded source vschema provided\")\n}","typeGuard":null,"tryCatchPattern":"if err := switchTraffic(ctx, ks, wf); err != nil {\n    if strings.Contains(err.Error(), \"no sharded vschema was provided\") {\n        // apply target vschema manually, then retry the switch\n    }\n    return err\n}","preventionTips":["Ensure the source keyspace has a valid sharded vschema before MoveTables","Pre-apply the target vschema for sharded targets","Test vschema copying in a staging cluster before production cutover"],"tags":["vitess","vschema","vindex","traffic-switch"],"backgroundTag":"missing-sharded-vschema","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}