vitessio/vitess · error

unknown workflow type %d

Error message

unknown workflow type %d

What it means

VReplicationWorkflow.Create only knows how to initialize MoveTables, Migrate, and Reshard workflow types. A VReplicationWorkflow constructed with any other workflowType falls through to the default case and is rejected.

Source

Thrown at go/vt/wrangler/workflow.go:255

	}
	if vrw.CachedState() != WorkflowStateNotCreated {
		return fmt.Errorf("workflow has already been created, state is %s", vrw.CachedState())
	}
	switch vrw.workflowType {
	case MoveTablesWorkflow, MigrateWorkflow:
		err = vrw.initMoveTables()
	case ReshardWorkflow:
		excludeTables := strings.Split(vrw.params.ExcludeTables, ",")
		keyspace := vrw.params.SourceKeyspace

		vschmErr := vrw.wr.ValidateVSchema(ctx, keyspace, vrw.params.SourceShards, excludeTables, true /*includeViews*/)
		if vschmErr != nil {
			return fmt.Errorf("Create ReshardWorkflow failed: %v", vschmErr)
		}

		err = vrw.initReshard()
	default:
		return fmt.Errorf("unknown workflow type %d", vrw.workflowType)
	}
	if err != nil {
		return err
	}
	return nil
}

// WorkflowError has per stream errors if present in a workflow
type WorkflowError struct {
	Tablet      string
	ID          int32
	Description string
}

// NewWorkflowError returns a new WorkflowError object
func NewWorkflowError(tablet string, id int32, description string) *WorkflowError {
	wfErr := &WorkflowError{
		Tablet:      tablet,

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Use the correct workflow type constant (MoveTablesWorkflow, MigrateWorkflow, ReshardWorkflow) when constructing the VReplicationWorkflow
  2. Use the type-specific API for other workflow kinds instead of the generic Create
  3. Check the numeric type printed in the error against the wrangler's workflow type constants

Example fix

// before
wf := wr.NewVReplicationWorkflow(ctx, ..., wrangler.MaterializationWorkflow, params)
wf.Create(ctx)
// after (materialize has its own path)
wr.Materialize(ctx, ...)

wf := wr.NewVReplicationWorkflow(ctx, ..., wrangler.MoveTablesWorkflow, params)
wf.Create(ctx)
Defensive patterns

Strategy: validation

Validate before calling

switch wfType {
case wrangler.MoveTablesWorkflow, wrangler.MigrateWorkflow, wrangler.ReshardWorkflow:
    // supported
default:
    return fmt.Errorf("workflow type %d has no generic Create path", wfType)
}

Type guard

func creatableViaGenericCreate(t int) bool {
    switch t {
    case int(wrangler.MoveTablesWorkflow), int(wrangler.MigrateWorkflow), int(wrangler.ReshardWorkflow):
        return true
    }
    return false
}

Prevention

When it happens

Trigger: Calling Create() on a VReplicationWorkflow whose workflowType is not one of MoveTablesWorkflow, MigrateWorkflow, or ReshardWorkflow (e.g. a type that must be created through a different API).

Common situations: Constructing the generic VReplicationWorkflow wrapper for a workflow type (like LookupVindex or materialization flows) that has its own dedicated creation path.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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