vitessio/vitess · error
no target shards specified for workflow %s
Error message
no target shards specified for workflow %s
What it means
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.
Source
Thrown at go/vt/vtctl/workflow/materializer.go:546
// that would be filtered out by the vindex anyway.
var specifiedTargetShards []string
switch {
case mz.IsMultiTenantMigration():
specifiedTargetShards = ms.WorkflowOptions.Shards
case len(ms.SourceShards) > 0: // shard-by-shard migration
specifiedTargetShards = ms.SourceShards
}
if len(specifiedTargetShards) > 0 {
var targetShards2 []*topo.ShardInfo
for _, shard := range targetShards {
if slices.Contains(specifiedTargetShards, shard.ShardName()) {
targetShards2 = append(targetShards2, shard)
}
}
targetShards = targetShards2
}
if len(targetShards) == 0 {
return fmt.Errorf("no target shards specified for workflow %s ", ms.Workflow)
}
sourceTs := mz.ts
if ms.ExternalCluster != "" { // when the source is an external mysql cluster mounted using the Mount command
externalTopo, err := mz.ts.OpenExternalVitessClusterServer(ctx, ms.ExternalCluster)
if err != nil {
return fmt.Errorf("failed to open external topo: %v", err)
}
sourceTs = externalTopo
}
differentPVs := false
sourceVSchema, err := sourceTs.GetVSchema(ctx, ms.SourceKeyspace)
if err != nil {
return fmt.Errorf("failed to get source keyspace vschema: %v", err)
}
differentPVs = primaryVindexesDiffer(ms, sourceVSchema.Keyspace, vschema.Keyspace)
mz.targetVSchema = targetVSchemaView on GitHub (pinned to 01a25a7d17)
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
Example fix
// before MoveTables --target-keyspace=copy --target-shards=xyz // after MoveTables --target-keyspace=copy --target-shards=0-
Defensive patterns
Strategy: validation
Validate before calling
shards, err := ts.GetShardNames(ctx, targetKeyspace)
if err != nil { return err }
if len(shards) == 0 {
return fmt.Errorf("target keyspace %s has no shards; init them first", targetKeyspace)
} Try / catch
if err := createWorkflow(ctx, req); err != nil {
if strings.Contains(err.Error(), "no target shards specified") {
// verify target keyspace shards and fix --target-shards
}
return err
} Prevention
- Initialize target keyspace shards and tablets before workflow creation
- Validate --target-shards against GetShardNames output
- Use reshard planning tools that generate valid shard ranges
When it happens
Trigger: 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.
Common situations: --target-shards flag typo; target keyspace freshly created with no shards yet; shard names not matching topo convention; target keyspace name misspelled.
Related errors
- no source shards specified for workflow %s
- both atomic copy and partial mode cannot be specified for th
- invalid workflow
- multiple source keyspaces for a single workflow
- multiple target keyspaces for a single workflow
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/67b426afb0269787.
Report an issue: GitHub.