{"record":{"id":"0ccea716f91c8dc7","repo":"vitessio/vitess","slug":"unexpected-diff-action","errorCode":null,"errorMessage":"unexpected diff action","messagePattern":"unexpected diff action","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/schemadiff/errors.go","lineNumber":31,"sourceCode":"See the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage schemadiff\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"strings\"\n\n\t\"vitess.io/vitess/go/sqlescape\"\n\t\"vitess.io/vitess/go/vt/sqlparser\"\n)\n\nvar (\n\tErrEntityTypeMismatch             = errors.New(\"mismatched entity type\")\n\tErrStrictIndexOrderingUnsupported = errors.New(\"strict index ordering is unsupported\")\n\tErrUnexpectedDiffAction           = errors.New(\"unexpected diff action\")\n\tErrUnexpectedTableSpec            = errors.New(\"unexpected table spec\")\n\tErrExpectedCreateTable            = errors.New(\"expected a CREATE TABLE statement\")\n\tErrExpectedCreateView             = errors.New(\"expected a CREATE VIEW statement\")\n)\n\ntype ImpossibleApplyDiffOrderError struct {\n\tUnorderedDiffs   []EntityDiff\n\tConflictingDiffs []EntityDiff\n}\n\nfunc (e *ImpossibleApplyDiffOrderError) Error() string {\n\tvar b strings.Builder\n\tconflictingStatements := e.ConflictingStatements()\n\tfmt.Fprintf(&b, \"no valid applicable order for diffs. %d diffs found conflicting:\", len(conflictingStatements))\n\tfor _, s := range conflictingStatements {\n\t\tb.WriteString(\"\\n\")\n\t\tb.WriteString(s)\n\t}","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/schemadiff/errors.go#L13-L49","documentation":"ErrUnexpectedDiffAction is returned by DDLActionStr when it encounters a sqlparser.DDLAction value it has no string mapping for. This usually means a new DDL action was added to the parser without updating schemadiff's action-to-string table, or an uninitialized/invalid action was passed.","triggerScenarios":"Calling schemadiff.DDLActionStr with a DDLAction not covered by its switch; parser version drift where a new action type reaches schemadiff.","commonSituations":"Upgrading Vitess/sqlparser and custom code exercising new DDL actions; passing a zero-value or otherwise invalid DDLAction.","solutions":["Check that the sqlparser and schemadiff versions match (rebuild the whole module)","Add a case for the new DDLAction in DDLActionStr if extending the code","Log/inspect the DDLAction value being passed in"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"switch action {\ncase sqlparser.AlterDropPrimaryKey, sqlparser.AlterAddColumn /* known actions */ :\n\t// safe\ndefault:\n\t// unknown action for DDLActionStr\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n\tif errors.Is(err, schemadiff.ErrUnexpectedDiffAction) {\n\t\tlog.Warnf(\"unmapped DDL action %v\", action)\n\t}\n}","preventionTips":["Keep sqlparser and schemadiff versions in sync","Add mappings for new DDL actions when upgrading","Never pass zero-value DDLAction values"],"tags":["schemadiff","ddl","action-mapping"],"backgroundTag":"unexpected-value","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}