vitessio/vitess · error
unknown ASTStep
Error message
unknown ASTStep
What it means
In the generated AST-path machinery, DebugString maps each ASTStep enum value to a human-readable path element name. When a step value has no case in the switch, it panics 'unknown ASTStep', meaning a new step constant was added without updating this (manually maintained) integration file. Used for debugging AST paths collected during rewriting.
Source
Thrown at go/tools/asthelpergen/integration/ast_path.go:85
return "(ValueSliceContainer).ASTImplementationElements"
case SliceOfASTOffset:
return "([]AST)[]Offset"
case SliceOfRefOfLeafOffset:
return "([]*Leaf)[]Offset"
case RefOfValueContainerASTType:
return "(*ValueContainer).ASTType"
case RefOfValueContainerASTImplementationType:
return "(*ValueContainer).ASTImplementationType"
case RefOfValueSliceContainerASTElementsOffset:
return "(*ValueSliceContainer).ASTElementsOffset"
case RefOfValueSliceContainerASTImplementationElements:
return "(*ValueSliceContainer).ASTImplementationElements"
case RefOfOptionsl:
return "(*Options).l"
case VisitableInner:
return "VisitableInner"
}
panic("unknown ASTStep")
}
func GetNodeFromPath(node AST, path ASTPath) AST {
for len(path) >= 2 {
step := path.nextPathStep()
path = path[2:]
switch step {
case InterfaceSliceOffset:
idx, bytesRead := path.nextPathOffset()
path = path[bytesRead:]
node = node.(InterfaceSlice)[idx]
case LeafSliceOffset:
idx, bytesRead := path.nextPathOffset()
path = path[bytesRead:]
node = node.(LeafSlice)[idx]
case RefOfRefContainerASTType:
node = node.(*RefContainer).ASTType
case RefOfRefContainerASTImplementationType:View on GitHub (pinned to 01a25a7d17)
Solutions
- Add a case for the missing step constant in the DebugString switch in go/tools/asthelpergen/integration/ast_path.go
- Regenerate/update the integration files so the step enum and DebugString stay in sync
- As a workaround, use GetNodeFromPath directly instead of DebugString for the path in question
Example fix
// before case VisitableInner: return "VisitableInner" } // after case VisitableInner: return "VisitableInner" case NewStepKind: return "(*SomeNode).NewField" }
Defensive patterns
Strategy: validation
Validate before calling
// Ensure every ASTStep constant has a DebugString case
for step := range allASTSteps {
if nameForStep(step) == "" {
log.Fatalf("ASTStep %d missing DebugString case", step)
}
} Prevention
- Whenever you add an ASTStep constant, add its DebugString case in the same PR
- Grep ast_path.go for the step constant list before regenerating
- Keep a test that DebugString-prints a path containing every step kind
When it happens
Trigger: Collecting an ASTPath (a.collectPaths / AddStep) whose step constant is not listed in DebugString's switch, then calling DebugString on it; typically after adding a new node/field step constant in go/tools/asthelpergen without updating ast_path.go.
Common situations: A developer adds a new AST node type or field, the enum grows, and a debug print of a collected path crashes during sqlparser work or tests that enable path collection.
Related errors
- [BUG] tried to replace 'ASTType' on 'ValueContainer'
- unknown ASTStep
- table expression is complex
- package '%s' does not contain 'ast_format.go'
- generator failed for type %s: %w
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/2f8b96b42adbdb6f.
Report an issue: GitHub.