{"record":{"id":"67b426afb0269787","repo":"vitessio/vitess","slug":"no-target-shards-specified-for-workflow-s","errorCode":null,"errorMessage":"no target shards specified for workflow %s ","messagePattern":"no target shards specified for workflow (.+?) ","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtctl/workflow/materializer.go","lineNumber":546,"sourceCode":"\t// that would be filtered out by the vindex anyway.\n\tvar specifiedTargetShards []string\n\tswitch {\n\tcase mz.IsMultiTenantMigration():\n\t\tspecifiedTargetShards = ms.WorkflowOptions.Shards\n\tcase len(ms.SourceShards) > 0: // shard-by-shard migration\n\t\tspecifiedTargetShards = ms.SourceShards\n\t}\n\tif len(specifiedTargetShards) > 0 {\n\t\tvar targetShards2 []*topo.ShardInfo\n\t\tfor _, shard := range targetShards {\n\t\t\tif slices.Contains(specifiedTargetShards, shard.ShardName()) {\n\t\t\t\ttargetShards2 = append(targetShards2, shard)\n\t\t\t}\n\t\t}\n\t\ttargetShards = targetShards2\n\t}\n\tif len(targetShards) == 0 {\n\t\treturn fmt.Errorf(\"no target shards specified for workflow %s \", ms.Workflow)\n\t}\n\n\tsourceTs := mz.ts\n\tif ms.ExternalCluster != \"\" { // when the source is an external mysql cluster mounted using the Mount command\n\t\texternalTopo, err := mz.ts.OpenExternalVitessClusterServer(ctx, ms.ExternalCluster)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to open external topo: %v\", err)\n\t\t}\n\t\tsourceTs = externalTopo\n\t}\n\tdifferentPVs := false\n\tsourceVSchema, err := sourceTs.GetVSchema(ctx, ms.SourceKeyspace)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get source keyspace vschema: %v\", err)\n\t}\n\tdifferentPVs = primaryVindexesDiffer(ms, sourceVSchema.Keyspace, vschema.Keyspace)\n\n\tmz.targetVSchema = targetVSchema","sourceCodeStart":528,"sourceCodeEnd":564,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtctl/workflow/materializer.go#L528-L564","documentation":"buildMaterializer requires at least one target shard in the target keyspace. After applying the ms.TargetShards filter, if the target shard list is empty, the workflow has nowhere to write and this error is returned.","triggerScenarios":"createWorkflowStreamels or WorkflowAddTables builds a materializer where ms.TargetShards was specified but filtered to an empty set, or the target keyspace has no serving shards.","commonSituations":"--target-shards flag typo; target keyspace freshly created with no shards yet; shard names not matching topo convention; target keyspace name misspelled.","solutions":["List valid shards with `vtctl GetShardNames <target-keyspace>` and correct the target shard specification","Omit the target-shards filter to use all target shards","Initialize the target keyspace with shards before creating the workflow"],"exampleFix":"// before\nMoveTables --target-keyspace=copy --target-shards=xyz\n// after\nMoveTables --target-keyspace=copy --target-shards=0-","handlingStrategy":"validation","validationCode":"shards, err := ts.GetShardNames(ctx, targetKeyspace)\nif err != nil { return err }\nif len(shards) == 0 {\n    return fmt.Errorf(\"target keyspace %s has no shards; init them first\", targetKeyspace)\n}","typeGuard":null,"tryCatchPattern":"if err := createWorkflow(ctx, req); err != nil {\n    if strings.Contains(err.Error(), \"no target shards specified\") {\n        // verify target keyspace shards and fix --target-shards\n    }\n    return err\n}","preventionTips":["Initialize target keyspace shards and tablets before workflow creation","Validate --target-shards against GetShardNames output","Use reshard planning tools that generate valid shard ranges"],"tags":["vitess","workflow","resharding","shards","configuration"],"backgroundTag":"no-target-shards","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}