vitessio/vitess · error

%w in keyspace %s for %s

Error message

%w in keyspace %s for %s

What it means

BuildTargets collects the target shards/streams for a workflow in the target keyspace; if it ends up with zero targets, it returns this error wrapping the sentinel ErrNoStreams, including the keyspace and workflow name. It means no running vreplication streams (target tablets) were found for the workflow, so traffic switching or workflow operations cannot proceed.

Source

Thrown at go/vt/vtctl/workflow/utils.go:427

		optionsJSON := wf.GetOptions()
		if optionsJSON != "" {
			if err := json.Unmarshal([]byte(optionsJSON), &options); err != nil {
				return nil, vterrors.Wrapf(err, "failed to unmarshal options: %s", optionsJSON)
			}
		}

		for _, stream := range wf.Streams {
			if stream.Message == Frozen {
				frozen = true
			}
			target.Sources[stream.Id] = stream.Bls
		}

		targets[targetShardName] = target
	}

	if len(targets) == 0 {
		return nil, fmt.Errorf("%w in keyspace %s for %s", ErrNoStreams, targetKeyspace, workflow)
	}

	return &TargetInfo{
		Targets:         targets,
		Frozen:          frozen,
		OptCells:        optCells,
		OptTabletTypes:  optTabletTypes,
		WorkflowType:    workflowType,
		WorkflowSubType: workflowSubType,
		Options:         &options,
	}, nil
}

func getSourceAndTargetKeyRanges(sourceShards, targetShards []string) (*topodatapb.KeyRange, *topodatapb.KeyRange, error) {
	if len(sourceShards) == 0 || len(targetShards) == 0 {
		return nil, nil, errors.New("either source or target shards are missing")
	}

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Verify the workflow name and keyspace with `Workflow GetWorkflows` / vtctldclient GetWorkflows; correct typos.
  2. Check that the workflow still has active streams (`Show` on the workflow / query the _vt.vreplication table on target primaries).
  3. If the workflow already finished, use the appropriate command (e.g. it is already complete) instead of switching traffic; if it should be running, restart/recreate it.

Example fix

// before
vtctldclient MoveTables --workflow wrong_name --target-keyspace customer SwitchTraffic
// error: no streams in keyspace customer for wrong_name
// after
vtctldclient GetWorkflows --keyspace customer
vtctldclient MoveTables --workflow sales2customer --target-keyspace customer SwitchTraffic
Defensive patterns

Strategy: validation

Validate before calling

// check the workflow has streams before switching traffic
out, err := exec.Command("vtctldclient", "GetWorkflows", "--keyspace", ks).Output()
if err != nil || !strings.Contains(string(out), workflow) {
    return fmt.Errorf("workflow %s not found in %s", workflow, ks)
}

Try / catch

if err := ts.SwitchTraffic(ctx, workflow); err != nil {
    if errors.Is(err, workflow.ErrNoStreams) {
        // workflow missing/already finished: inspect GetWorkflows and re-plan
        return inspectAndReplan(workflow)
    }
    return err
}

Prevention

When it happens

Trigger: Calling a workflow command (SwitchTraffic/Complete/Cancel, via buildTrafficSwitcher) on a workflow that has no vreplication streams — e.g. the workflow was already completed/cancelled, never started, or targets are down — and GetWorkflows/streams queries return nothing.

Common situations: Running CompleteMoveTables twice; wrong -workflow name typo; workflow exists in a different keyspace; target tablets removed or workflow streams purged before switching traffic.

Related errors


AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01). Data as JSON: /api/errors/2df078359f476fbc. Report an issue: GitHub.