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

  1. Read each diagnostic line in the error—each is a separate HCL problem with file/line context
  2. Fix the reported HCL syntax/type issues at the indicated line numbers
  3. Validate the jobspec with nomad job validate before submitting
  4. 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

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


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/e12e99dc5751af1c. Report an issue: GitHub.