gastownhall/beads · error
step %q: %w
Error message
step %q: %w
What it means
FilterStepsByCondition evaluates each Step.Condition via EvaluateStepCondition and wraps any evaluation error with the offending step's ID using this prefix. It identifies which step in the formula has the bad condition, with the underlying cause (e.g. invalid condition format) appended via %w.
Source
Thrown at internal/formula/stepcondition.go:129
// Children of excluded steps are also excluded.
//
// Parameters:
// - steps: the steps to filter
// - vars: variable values for condition evaluation
//
// Returns the filtered steps and any error encountered during evaluation.
func FilterStepsByCondition(steps []*Step, vars map[string]string) ([]*Step, error) {
if vars == nil {
vars = make(map[string]string)
}
result := make([]*Step, 0, len(steps))
for _, step := range steps {
// Evaluate step condition
include, err := EvaluateStepCondition(step.Condition, vars)
if err != nil {
return nil, fmt.Errorf("step %q: %w", step.ID, err)
}
if !include {
// Skip this step and all its children
continue
}
// Clone the step to avoid mutating input
clone := cloneStep(step)
// Recursively filter children
if len(step.Children) > 0 {
filteredChildren, err := FilterStepsByCondition(step.Children, vars)
if err != nil {
return nil, err
}
clone.Children = filteredChildren
}View on GitHub (pinned to 71377f2769)
Solutions
- Read the step ID from the error message to locate the offending step in the formula file.
- Fix that step's condition to a supported format (see EvaluateStepCondition).
- Temporarily remove the condition to confirm the rest of the formula works, then restore a corrected condition.
Example fix
// before (step deploy)
condition: "{{env}} == prod && {{approved}}"
// after
condition: "{{env}} == prod" Defensive patterns
Strategy: try-catch
Validate before calling
for _, s := range steps {
if _, err := EvaluateStepCondition(s.Condition, vars); err != nil {
return fmt.Errorf("pre-check failed for step %q: %w", s.ID, err)
}
} Try / catch
if err := FilterStepsByCondition(steps, vars); err != nil {
var stepID string
if m := regexp.MustCompile(`step "([^"]+)"`).FindStringSubmatch(err.Error()); m != nil { stepID = m[1] }
return fmt.Errorf("fix condition on step %q: %w", stepID, err)
} Prevention
- Pre-validate all step conditions before filtering so errors surface with context.
- Keep step IDs stable and meaningful so error messages are actionable.
- Add a schema check on formula load that only permits supported condition syntax.
When it happens
Trigger: Filtering steps where any step's Condition is malformed — EvaluateStepCondition returns an error and it is re-wrapped as `step "<id>": <cause>`.
Common situations: Running a formula whose YAML/TOML defines a condition the evaluator cannot parse; the error surfaces during formula instantiation or step filtering with the culprit step named.
Related errors
- resolve parent %s: %w
- invalid step condition format: %q (expected {{var}} or {{var
- not found
- resolve proxied server root: %w
- parsing formula: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/9c1cdb7d4e50cf5c.
Report an issue: GitHub.