hashicorp/packer · error

unhandled node type %s

Error message

unhandled node type %s

What it means

Internal error from the HCL2 upgrade command's Go template walker (reTemplate): the parsed template AST contains a text/template node type the converter does not handle (anything other than Action/Command/List/Text nodes). Indicates unsupported Go templating syntax in the legacy JSON template.

Source

Thrown at command/hcl2_upgrade.go:354

		// Escape anything that isn't in the func map
		fmt.Fprintf(out, "{{ \"{{\" }} %s {{ \"}}\" }}", cmd.String())

	// TODO maybe node.Pipe.Decls? Though in Packer templates they're not
	// supported officially so they can be left aside for now
	case *parse.ListNode:
		for _, child := range node.Nodes {
			err := reTemplate(child, out, funcs)
			if err != nil {
				return err
			}
		}
	case *parse.TextNode:
		_, err := fmt.Fprintf(out, "%s", node.Text)
		if err != nil {
			return err
		}
	default:
		return fmt.Errorf("unhandled node type %s", reflect.TypeOf(nd))
	}
	return nil
}

// transposeTemplatingCalls executes parts of blocks as go template files and replaces
// their result with their hcl2 variant. If something goes wrong the template
// containing the go template string is returned.
func transposeTemplatingCalls(s []byte) []byte {
	funcErrors := &multierror.Error{
		ErrorFormat: func(es []error) string {
			if len(es) == 1 {
				return fmt.Sprintf("# 1 error occurred upgrading the following block:\n\t# %s\n", es[0])
			}

			points := make([]string, len(es))
			for i, err := range es {
				if i == len(es)-1 {
					points[i] = fmt.Sprintf("# %s", err)

View on GitHub (pinned to eb36e3c3e4)

Solutions

  1. Simplify the Go template expressions in the legacy template (remove branches, pipes, or variables not supported by the converter)
  2. Hand-migrate the offending template section to HCL2 after upgrading the rest
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at command/hcl2_upgrade.go:354 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05). Data as JSON: /api/errors/86241208004c3338. Report an issue: GitHub.