{"record":{"id":"4cdd3899eda6407c","repo":"vitessio/vitess","slug":"unknown-schema-migration-strategy-v","errorCode":null,"errorMessage":"unknown schema migration strategy: '%v'","messagePattern":"unknown schema migration strategy: '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtctl/schematools/schematools.go","lineNumber":60,"sourceCode":"\tsd, err := tmc.GetSchema(ctx, ti.Tablet, request)\n\tif err != nil {\n\t\treturn nil, vterrors.Wrapf(err, \"GetSchema(%v, %v) failed\", ti.Tablet, request)\n\t}\n\n\treturn sd, nil\n}\n\n// ParseSchemaMigrationStrategy parses the given strategy into the underlying enum type.\nfunc ParseSchemaMigrationStrategy(name string) (vtctldatapb.SchemaMigration_Strategy, error) {\n\tif name == \"\" {\n\t\t// backward compatiblity and to handle unspecified values\n\t\treturn vtctldatapb.SchemaMigration_DIRECT, nil\n\t}\n\n\tupperName := strings.ToUpper(name)\n\tstrategy, ok := vtctldatapb.SchemaMigration_Strategy_value[upperName]\n\tif !ok {\n\t\treturn 0, fmt.Errorf(\"unknown schema migration strategy: '%v'\", name)\n\t}\n\n\treturn vtctldatapb.SchemaMigration_Strategy(strategy), nil\n}\n\n// ParseSchemaMigrationStatus parses the given status into the underlying enum type.\nfunc ParseSchemaMigrationStatus(name string) (vtctldatapb.SchemaMigration_Status, error) {\n\tkey := strings.ToUpper(name)\n\n\tval, ok := vtctldatapb.SchemaMigration_Status_value[key]\n\tif !ok {\n\t\treturn 0, fmt.Errorf(\"unknown enum name for SchemaMigration_Status: %s\", name)\n\t}\n\n\treturn vtctldatapb.SchemaMigration_Status(val), nil\n}\n\n// SchemaMigrationStrategyName returns the text-based form of the strategy.","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtctl/schematools/schematools.go#L42-L78","documentation":"ParseSchemaMigrationStrategy converts a user-supplied strategy name (e.g. from an online DDL migration request) into the vtctldatapb.SchemaMigration_Strategy enum by upper-casing and looking it up in the generated enum value map. If the name does not match any known strategy, this error is returned. It is a pure input-validation error before any migration is started.","triggerScenarios":"Calling ParseSchemaMigrationStrategy with a string other than the valid strategies (e.g. \"mysql\"/\"maria\" expected values like \"DIRECT\"/\"Online\" depending on the enum): typically bad -strategy flag or bad row value when converting a row to SchemaMigration.","commonSituations":"Typo in an online DDL strategy flag (`-strategy`); strategy supplied by an automation script using a value from a different Vitess version; case/format issues like trailing whitespace or hyphen vs underscore.","solutions":["Use an exact valid strategy name; check proto/vtctldata.proto SchemaMigration.Strategy for the accepted values.","Trim whitespace and retry — lookup is exact after ToUpper.","If the value came from an older/newer Vitess version, align client tooling with the current enum names.","List valid values programmatically: keys of vtctldatapb.SchemaMigration_Strategy_value."],"exampleFix":"// before\nstrategy, err := schematools.ParseSchemaMigrationStrategy(\"gh-ost\") // unknown\n// after\nstrategy, err := schematools.ParseSchemaMigrationStrategy(\"online\") // or another valid enum name","handlingStrategy":"validation","validationCode":"validStrategies := map[string]bool{\"direct\": true, \"online\": true}\nif !validStrategies[strings.ToLower(strings.TrimSpace(strategyName))] {\n  return fmt.Errorf(\"strategy %q not in %v\", strategyName, validStrategies)\n}","typeGuard":"func isValidMigrationStrategy(name string) bool {\n  _, ok := vtctldatapb.SchemaMigration_Strategy_value[strings.ToUpper(strings.TrimSpace(name))]\n  return ok\n}","tryCatchPattern":"strategy, err := schematools.ParseSchemaMigrationStrategy(name)\nif err != nil {\n  return fmt.Errorf(\"bad -strategy value %q: %w (valid: direct, online)\", name, err)\n}","preventionTips":["Reference the generated enum names in proto/vtctldata.proto instead of hardcoding strings.","Trim and upper-case user input before parsing.","Pin client automation to the Vitess version whose enum names it targets.","Surface the list of valid values in CLI help/errors."],"tags":["validation","enum","online-ddl","schema-migration"],"backgroundTag":"invalid-enum-value","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}