hashicorp/nomad · error
<combined HCL diagnostics from str.String()>
Error message
<combined HCL diagnostics from str.String()>
What it means
decode in jobspec2/parse.go aggregates all HCL diagnostic messages (body decoding, decodeMapInterfaceType for Job/Tasks/Vault/Secrets, etc.) into a single error via a strings.Builder, so this message is the combined HCL diagnostics text from str.String(). It signals the jobspec failed schema/body validation during parsing.
Source
Thrown at jobspec2/parse.go:171
}
// Return early if the input job or variable files are not valid.
// Decoding and evaluating invalid files may result in unexpected results.
if diags.HasErrors() {
return diags
}
diags = append(diags, c.decodeBody(file.Body)...)
if diags.HasErrors() {
var str strings.Builder
for i, diag := range diags {
if i != 0 {
str.WriteByte('\n')
}
str.WriteString(diag.Error())
}
return errors.New(str.String())
}
diags = append(diags, decodeMapInterfaceType(&c.Job, c.EvalContext())...)
diags = append(diags, decodeMapInterfaceType(&c.Tasks, c.EvalContext())...)
diags = append(diags, decodeMapInterfaceType(&c.Vault, c.EvalContext())...)
diags = append(diags, decodeMapInterfaceType(&c.Secrets, c.EvalContext())...)
if diags.HasErrors() {
return diags
}
return nil
}
func parseFile(path string) (*hcl.File, hcl.Diagnostics) {
body, err := os.ReadFile(path)
if err != nil {
return nil, hcl.Diagnostics{View on GitHub (pinned to 482b49bf1a)
Solutions
- Read each diagnostic line in the error—each is a separate HCL problem with file/line context
- Fix the reported HCL syntax/type issues at the indicated line numbers
- Validate the jobspec with nomad job validate before submitting
- Check schema of Job/Tasks/Vault/Secrets stanzas against current Nomad version docs
Example fix
// broken jobspec
job "x" {
group "g" {
task "t" {
driver = "docker"
resources {
cpu = "500" // wrong: cpu is an int, not a string
}
}
}
}
// fixed
job "x" {
group "g" {
task "t" {
driver = "docker"
resources {
cpu = 500
}
}
}
} Defensive patterns
Strategy: validation
Validate before calling
// validate before parsing
// nomad job validate <file>
// or in Go: pre-scan the HCL body with hclparse and surface diags early
parser := hclparse.NewParser()
_, diags := parser.ParseHCLFile(path)
if diags.HasErrors() { return diags } Try / catch
if err := decode(...); err != nil {
// err contains newline-separated HCL diagnostics; print each line
for _, line := range strings.Split(err.Error(), "\n") {
log.Printf("hcl: %s", line)
}
} Prevention
- Run nomad job validate (or hcl2 linters) in CI for all jobspecs
- Keep stanzas (Job/Tasks/Vault/Secrets) schema-compliant with the target Nomad version
- Fix diagnostics from the top down—earlier errors often cascade
- Pin Nomad API version when jobspec syntax changes
When it happens
Trigger: Calling parseWithConfigImpl (and thus decode) with an HCL file whose body fails evaluation: invalid attributes/blocks, type mismatches in the Job/Tasks/Vault/Secrets maps, or any HCL diagnostic emitted during decode.
Common situations: Typo'd job attributes, wrong types (string where number expected), unsupported blocks, invalid Vault/Tasks/Secrets stanza structure in a Nomad jobspec, missing required fields.
Related errors
- command cannot be empty
- hostname cannot be set on task group using %q networking mod
- Unable to parse job submission to re-enable scaling policies
- error parsing: root should be an object
- limit should be an object
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/e12e99dc5751af1c.
Report an issue: GitHub.