vitessio/vitess · error
unexpected diff action
Error message
unexpected diff action
What it means
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.
Source
Thrown at go/vt/schemadiff/errors.go:31
See the License for the specific language governing permissions and
limitations under the License.
*/
package schemadiff
import (
"errors"
"fmt"
"strings"
"vitess.io/vitess/go/sqlescape"
"vitess.io/vitess/go/vt/sqlparser"
)
var (
ErrEntityTypeMismatch = errors.New("mismatched entity type")
ErrStrictIndexOrderingUnsupported = errors.New("strict index ordering is unsupported")
ErrUnexpectedDiffAction = errors.New("unexpected diff action")
ErrUnexpectedTableSpec = errors.New("unexpected table spec")
ErrExpectedCreateTable = errors.New("expected a CREATE TABLE statement")
ErrExpectedCreateView = errors.New("expected a CREATE VIEW statement")
)
type ImpossibleApplyDiffOrderError struct {
UnorderedDiffs []EntityDiff
ConflictingDiffs []EntityDiff
}
func (e *ImpossibleApplyDiffOrderError) Error() string {
var b strings.Builder
conflictingStatements := e.ConflictingStatements()
fmt.Fprintf(&b, "no valid applicable order for diffs. %d diffs found conflicting:", len(conflictingStatements))
for _, s := range conflictingStatements {
b.WriteString("\n")
b.WriteString(s)
}View on GitHub (pinned to 01a25a7d17)
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
Defensive patterns
Strategy: try-catch
Validate before calling
switch action {
case sqlparser.AlterDropPrimaryKey, sqlparser.AlterAddColumn /* known actions */ :
// safe
default:
// unknown action for DDLActionStr
} Try / catch
if err != nil {
if errors.Is(err, schemadiff.ErrUnexpectedDiffAction) {
log.Warnf("unmapped DDL action %v", action)
}
} Prevention
- Keep sqlparser and schemadiff versions in sync
- Add mappings for new DDL actions when upgrading
- Never pass zero-value DDLAction values
When it happens
Trigger: Calling schemadiff.DDLActionStr with a DDLAction not covered by its switch; parser version drift where a new action type reaches schemadiff.
Common situations: Upgrading Vitess/sqlparser and custom code exercising new DDL actions; passing a zero-value or otherwise invalid DDLAction.
Related errors
- unexpected table spec
- expected a CREATE TABLE statement
- found no possible unique key on `%s`
- BeforeSchema differs
- AfterSchema differs
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/0ccea716f91c8dc7.
Report an issue: GitHub.