hashicorp/nomad · error
generated unexpected hil type: %s
Error message
generated unexpected hil type: %s
What it means
InterpolateHIL evaluates a bind-name or token-name template with HIL and expects a string result. If HIL returns a non-string type (e.g. the template evaluates arithmetic/boolean expressions), this error is thrown.
Source
Thrown at lib/auth/binder.go:220
vm[k] = ast.Variable{
Type: ast.TypeString,
Value: v,
}
}
config := &hil.EvalConfig{
GlobalScope: &ast.BasicScope{
VarMap: vm,
},
}
result, err := hil.Eval(tree, config)
if err != nil {
return "", err
}
if result.Type != hil.TypeString {
return "", fmt.Errorf("generated unexpected hil type: %s", result.Type)
}
return result.Value.(string), nil
}
View on GitHub (pinned to 482b49bf1a)
Solutions
- Rewrite the template so the expression yields a string (wrap in quotes or literal text)
- Use only string-typed claim variables in the template
- Simplify the template to plain literals and ${claim} substitutions
Example fix
// before
BindName: "${1 + 1}"
// after
BindName: "team-${index}" // where index is a string claim mapping Defensive patterns
Strategy: validation
Validate before calling
// reject templates that are pure expressions without literal text
func isPlainStringTemplate(tmpl string) bool {
return !regexp.MustCompile(`^\$\{[^}]*\}$`).MatchString(tmpl)
} Try / catch
if err != nil && strings.Contains(err.Error(), "unexpected hil type") {
return fmt.Errorf("bind template must evaluate to a string: %w", err)
} Prevention
- Use only ${stringVar} substitutions, never arithmetic or boolean HIL expressions
- Surround interpolations with literal text so the result is always a string
- Review templates copied from Terraform for HIL expression features
When it happens
Trigger: A BindName or token name template whose HIL expression evaluates to a number or boolean, e.g. "${1 + 1}" or a variable inserted as a non-string ast.Variable by a caller.
Common situations: Copy-pasted HIL from Terraform using expressions instead of plain string interpolation; template with only a numeric expression and no surrounding text.
Related errors
- cannot compute %q bind name for bind target: %w
- no signed workload identity available
- JWT login returned an empty secret
- JWT login did not return a token
- ACL token expired
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/4a597d77616acb77.
Report an issue: GitHub.