{"record":{"id":"d80daae6e1902d75","repo":"vitessio/vitess","slug":"invalid-state-for-stream-s-of-workflow-s-s","errorCode":null,"errorMessage":"invalid state for stream %s of workflow %s.%s","messagePattern":"invalid state for stream (.+?) of workflow (.+?)\\.(.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtctl/workflow/server.go","lineNumber":3677,"sourceCode":"\t\tAutoStart:                 req.AutoStart,\n\t\tNoRoutingRules:            req.NoRoutingRules,\n\t}\n\treturn s.moveTablesCreate(ctx, moveTablesCreateRequest, binlogdatapb.VReplicationWorkflowType_Migrate)\n}\n\n// getWorkflowStatus gets the overall status of the workflow by checking the status of all the streams. If all streams are not\n// in the same state, it returns the unknown state.\nfunc (s *Server) getWorkflowStatus(ctx context.Context, keyspace string, workflow string) (binlogdatapb.VReplicationWorkflowState, error) {\n\tworkflowStatus := binlogdatapb.VReplicationWorkflowState_Unknown\n\twf, err := s.GetWorkflow(ctx, keyspace, workflow, false, nil)\n\tif err != nil {\n\t\treturn workflowStatus, err\n\t}\n\tfor _, shardStream := range wf.GetShardStreams() {\n\t\tfor _, stream := range shardStream.GetStreams() {\n\t\t\tstate, ok := binlogdatapb.VReplicationWorkflowState_value[stream.State]\n\t\t\tif !ok {\n\t\t\t\treturn workflowStatus, fmt.Errorf(\"invalid state for stream %s of workflow %s.%s\", stream.State, keyspace, workflow)\n\t\t\t}\n\t\t\tcurrentStatus := binlogdatapb.VReplicationWorkflowState(state)\n\t\t\tif workflowStatus != binlogdatapb.VReplicationWorkflowState_Unknown && currentStatus != workflowStatus {\n\t\t\t\treturn binlogdatapb.VReplicationWorkflowState_Unknown, nil\n\t\t\t}\n\t\t\tworkflowStatus = currentStatus\n\t\t}\n\t}\n\treturn workflowStatus, nil\n}\n\n// WorkflowMirrorTraffic mirrors traffic from the source keyspace to the target keyspace.\nfunc (s *Server) WorkflowMirrorTraffic(ctx context.Context, req *vtctldatapb.WorkflowMirrorTrafficRequest) (*vtctldatapb.WorkflowMirrorTrafficResponse, error) {\n\tts, startState, err := s.getWorkflowState(ctx, req.Keyspace, req.Workflow)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n","sourceCodeStart":3659,"sourceCodeEnd":3695,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtctl/workflow/server.go#L3659-L3695","documentation":"When aggregating a workflow's status across all its shard streams, each stream's state string is mapped to the VReplicationWorkflowState enum. If the stored state string is not a valid enum value, the status computation cannot proceed and returns this error naming the stream and workflow.","triggerScenarios":"Calling WorkflowStatus (or any status aggregation, e.g. via Workflow server APIs / vtctld GetWorkflows) while a _vt.vreplication row holds a state string that is not one of the defined VReplicationWorkflowState values.","commonSituations":"Direct manual UPDATE of the state column with a typo'd value; state strings written by an incompatible (older/newer) Vitess version; corrupted vreplication rows from partial writes.","solutions":["Inspect the stream's state: SELECT state FROM _vt.vreplication WHERE workflow='<wf>'; and correct it to a valid value (e.g. 'Running', 'Stopped', 'Error').","Reset the stream to a known-good state via the workflow control commands (Workflow <name> Start/Stop).","Ensure all tablets run compatible Vitess versions during upgrades."],"exampleFix":"-- before\nUPDATE _vt.vreplication SET state='runing' WHERE id=<id>;\n-- after\nUPDATE _vt.vreplication SET state='Running' WHERE id=<id>;","handlingStrategy":"validation","validationCode":"-- Verify all stream states are valid enum values\nSELECT id, state FROM _vt.vreplication WHERE state NOT IN ('Unknown','Running','Stopping','Stopped','Error','Updating','Copying');","typeGuard":null,"tryCatchPattern":"wf, err := client.GetWorkflows(ctx, keyspace)\nif err != nil && strings.Contains(err.Error(), \"invalid state for stream\") {\n    // fix the invalid state value on the named shard, then re-query\n}","preventionTips":["Never hand-edit the state column with arbitrary strings","Use Workflow Start/Stop commands to change stream states","Keep all tablets on the same Vitess version during rolling upgrades"],"tags":["vreplication","status","enum","state"],"backgroundTag":"invalid-vreplication-state","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}