gastownhall/beads · error

inline expand on step %q: %q has no template steps

Error message

inline expand on step %q: %q has no template steps

What it means

Thrown when the formula referenced by a step's Expand field is correctly typed as an expansion but contains no template steps (its Template slice is empty). An expansion formula is useless without a template to instantiate, so the library rejects it rather than silently producing zero steps.

Source

Thrown at internal/formula/expand.go:481

	var result []*Step

	for _, step := range steps {
		// Check if this step has an inline expansion
		if step.Expand != "" {
			// Load the expansion formula
			expFormula, err := parser.LoadByName(step.Expand)
			if err != nil {
				return nil, fmt.Errorf("inline expand on step %q: loading %q: %w", step.ID, step.Expand, err)
			}

			if expFormula.Type != TypeExpansion {
				return nil, fmt.Errorf("inline expand on step %q: %q is not an expansion formula (type=%s)",
					step.ID, step.Expand, expFormula.Type)
			}

			if len(expFormula.Template) == 0 {
				return nil, fmt.Errorf("inline expand on step %q: %q has no template steps", step.ID, step.Expand)
			}

			// Merge formula default vars with step's ExpandVars overrides
			vars := mergeVars(expFormula, step.ExpandVars)

			// Expand the step using the template (reuse existing expandStep)
			expandedSteps, err := expandStep(step, expFormula.Template, 0, vars)
			if err != nil {
				return nil, fmt.Errorf("inline expand on step %q: %w", step.ID, err)
			}

			// Propagate the original step's dependencies to root steps of the expansion
			propagateTargetDeps(step, expandedSteps)

			// Recursively process expanded steps for nested inline expansions
			processedSteps, err := applyInlineExpansionsRecursive(expandedSteps, parser, depth+1)
			if err != nil {
				return nil, err

View on GitHub (pinned to 71377f2769)

Solutions

  1. Add at least one [[template]] step to the referenced expansion formula.
  2. Check for TOML syntax mistakes: [[template]] (array of tables) is required — a single [template] table may not populate the Template slice.
  3. Point the Expand field at a different, complete expansion formula.

Example fix

// before (expansion with no template)
formula = "scaffolding"
type = "expansion"
// after
formula = "scaffolding"
type = "expansion"
[[template]]
id = "create-files"
title = "Create {target.title} files"
Defensive patterns

Strategy: validation

Validate before calling

f, err := parser.LoadByName(step.Expand)
if err != nil {
	return err
}
if f.Type == formula.TypeExpansion && len(f.Template) == 0 {
	return fmt.Errorf("expansion %q declares no [[template]] steps", step.Expand)
}

Type guard

func hasTemplate(f *formula.Formula) bool {
	return f != nil && f.Type == formula.TypeExpansion && len(f.Template) > 0
}

Prevention

When it happens

Trigger: ApplyInlineExpansions loads an expansion formula whose file defines type="expansion" but has no [[template]] entries (empty template array), then attempts to expand a step with it.

Common situations: Author created the expansion formula skeleton but never filled in template steps; a template section was accidentally deleted or commented out; a TOML/JSON key typo (e.g. [template] single table instead of [[template]] array) yields an empty slice.

Related errors


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/cb5b7fabe3125eb5. Report an issue: GitHub.