hashicorp/nomad · error
Unable to parse job submission to re-enable scaling policies
Error message
Unable to parse job submission to re-enable scaling policies: %w
What it means
Raised in job_start.go's parseFromSubmission when the `nomad job start/revert`-related code path re-enables scaling policies and cannot parse the stored job submission as HCL2 via jobspec2.Parse. The wrapped cause carries the HCL diagnostic (line, expression) from the parser, so the error means the submission body in Nomad's job-submission store is invalid or not valid HCL2.
Source
Thrown at command/job_start.go:201
c.Ui.Output("Evaluation ID: " + resp.EvalID)
}
return 0
}
mon := newMonitor(c.Meta, client, length)
return mon.monitor(resp.EvalID)
}
func parseFromSubmission(sub *api.JobSubmission) (*api.Job, error) {
var job *api.Job
var err error
switch sub.Format {
case "hcl2":
job, err = jobspec2.Parse("", strings.NewReader(sub.Source))
if err != nil {
return nil, fmt.Errorf("Unable to parse job submission to re-enable scaling policies: %w", err)
}
case "json":
err = json.Unmarshal([]byte(sub.Source), &job)
if err != nil {
return nil, fmt.Errorf("Unable to parse job submission to re-enable scaling policies: %w", err)
}
}
return job, nil
}
View on GitHub (pinned to 482b49bf1a)
Solutions
- Read the wrapped HCL diagnostic to find the exact offending line/expression and fix the job HCL2 source.
- Re-register the job with valid HCL2 (nomad job run <file.hcl>) so the stored submission is replaced, then retry the scaling-policy re-enable.
- If the job is actually HCL1, submit it as JSON instead (nomad job run -output to convert) or update the tooling to parse with the hcl1 jobspec parser.
- Check for HCL2-only constructs vs. old syntax (e.g. `task { }` blocks written in HCL1 style) and migrate them.
Example fix
// before (HCL1-style submission stored, parsed as hcl2)
job "web" {
task "server" { driver = "docker" }
}
// after (valid HCL2)
job "web" {
group "web" {
task "server" {
driver = "docker"
}
}
} Defensive patterns
Strategy: validation
Validate before calling
# validate HCL2 before submitting nomad job run -output job.hcl > /dev/null || echo "HCL2 parse failed"
Type guard
func parsesAsHCL2(src string) error {
_, err := jobspec2.Parse("", strings.NewReader(src))
return err // nil means valid
} Try / catch
job, err := parseFromSubmission(sub)
if err != nil {
if strings.Contains(err.Error(), "Failed to parse") {
// surface the HCL diagnostic line to the user
}
return err
} Prevention
- Author jobs in HCL2 syntax and parse-verify with nomad job run -output before registering.
- Do not tag HCL bodies as hcl2 when they were written for the HCL1 jobspec parser.
- Keep the stored submission in sync with the working job file via CI (nomad job validate in the pipeline).
- Convert legacy HCL1 jobs explicitly rather than relying on re-parse.
When it happens
Trigger: sub.Format == "hcl2" and jobspec2.Parse fails on sub.Source: the stored submission contains HCL1-only syntax, template/variable references that cannot resolve in this context, or truncated/corrupted source stored with the job.
Common situations: Job was originally registered from HCL1 (jobspec) but the submission format is tagged hcl2; job deployed via CI with hcl1 parser; copy-pasted job body missing the closing brace; HCL2 dynamic variables unavailable during re-parse.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- error parsing hcl: %w
- error parsing: root should be an object
- <combined HCL diagnostics from str.String()>
- 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/c69b1698346c7ecc.
Report an issue: GitHub.