{"record":{"id":"de5be0ee1c763adc","repo":"vitessio/vitess","slug":"unknown-aststep-de5be0","errorCode":null,"errorMessage":"unknown ASTStep","messagePattern":"unknown ASTStep","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/sqlparser/ast_path.go","lineNumber":1777,"sourceCode":"\t\treturn \"([]VindexParam)[]Offset\"\n\tcase SliceOfRefOfCommonTableExprOffset:\n\t\treturn \"([]*CommonTableExpr)[]Offset\"\n\tcase RefOfIndexColumnColumn:\n\t\treturn \"(*IndexColumn).Column\"\n\tcase RefOfIndexColumnExpression:\n\t\treturn \"(*IndexColumn).Expression\"\n\tcase RefOfIndexOptionValue:\n\t\treturn \"(*IndexOption).Value\"\n\tcase RefOfTableAndLockTypeTable:\n\t\treturn \"(*TableAndLockType).Table\"\n\tcase RefOfRenameTablePairFromTable:\n\t\treturn \"(*RenameTablePair).FromTable\"\n\tcase RefOfRenameTablePairToTable:\n\t\treturn \"(*RenameTablePair).ToTable\"\n\tcase VisitableInner:\n\t\treturn \"VisitableInner\"\n\t}\n\tpanic(\"unknown ASTStep\")\n}\n\nfunc GetNodeFromPath(node SQLNode, path ASTPath) SQLNode {\n\tfor len(path) >= 2 {\n\t\tstep := path.nextPathStep()\n\t\tpath = path[2:]\n\t\tswitch step {\n\t\tcase RefOfAddColumnsColumnsOffset:\n\t\t\tidx, bytesRead := path.nextPathOffset()\n\t\t\tpath = path[bytesRead:]\n\t\t\tnode = node.(*AddColumns).Columns[idx]\n\t\tcase RefOfAddColumnsAfter:\n\t\t\tnode = node.(*AddColumns).After\n\t\tcase RefOfAddConstraintDefinitionConstraintDefinition:\n\t\t\tnode = node.(*AddConstraintDefinition).ConstraintDefinition\n\t\tcase RefOfAddIndexDefinitionIndexDefinition:\n\t\t\tnode = node.(*AddIndexDefinition).IndexDefinition\n\t\tcase RefOfAliasedExprExpr:","sourceCodeStart":1759,"sourceCodeEnd":1795,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/sqlparser/ast_path.go#L1759-L1795","documentation":"The generated ASTPath step-name resolver maps every ASTStep enum value to a string used for debugging/pretty-printing paths; an unknown step value falls out of the switch and panics. This indicates path corruption or a step enum produced by a mismatched code generation.","triggerScenarios":"Calling GetNodeFromPath (or path-name printing helpers) with an ASTPath containing a step value that is not a known ASTStep constant — e.g. paths built by a different parser build/version, or paths persisted across a regen that shifted enum numbering.","commonSituations":"Caching AST paths between Vitess versions; mixing generated files from different codegen runs; custom tools that fabricate ASTStep values numerically.","solutions":["Regenerate with `make codegen` so ASTStep constants and the name resolver come from the same generation","Rebuild cached/persisted AST paths with the current parser version instead of reusing old ones","Only construct ASTPaths via the official rewrite/collect APIs, never by hand with raw uint16 steps","Pin all components (parser producer and consumer) to the same Vitess version"],"exampleFix":"// before\npath := sqlparser.ASTPath{7, 3} // stale numeric steps\nnode := sqlparser.GetNodeFromPath(root, path)\n// after\n// collect fresh paths with the current build:\na := sqlparser.NewRewriter(...)\na.collectPaths = true\n// use steps produced by a.CollectPaths(root), not persisted old values","handlingStrategy":"validation","validationCode":"// Only use paths produced by the same build of the parser:\nfunc withCollectedPaths(root sqlparser.SQLNode, fn func()) {\n    // use sqlparser.RewriteOptions with CollectPaths enabled;\n    // never persist or hand-craft ASTPath step values\n    fn()\n}","typeGuard":null,"tryCatchPattern":"func nodeFromPathSafe(node sqlparser.SQLNode, path sqlparser.ASTPath) (res sqlparser.SQLNode, err error) {\n    defer func() {\n        if r := recover(); r != nil {\n            err = fmt.Errorf(\"path resolution panicked: %v\", r)\n        }\n    }()\n    return sqlparser.GetNodeFromPath(node, path), nil\n}","preventionTips":["Never persist ASTPaths across versions or builds","Only build paths via the official rewrite/collect APIs","Regenerate code with `make codegen` after parser changes","Pin producer and consumer to the same Vitess version"],"tags":["sqlparser","codegen","ast-path","panic"],"backgroundTag":"generated-code-version-mismatch","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}