{"record":{"id":"c69b1698346c7ecc","repo":"hashicorp/nomad","slug":"unable-to-parse-job-submission-to-re-enable-scalin","errorCode":null,"errorMessage":"Unable to parse job submission to re-enable scaling policies: %w","messagePattern":"Unable to parse job submission to re-enable scaling policies: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/job_start.go","lineNumber":201,"sourceCode":"\t\t\tc.Ui.Output(\"Evaluation ID: \" + resp.EvalID)\n\t\t}\n\n\t\treturn 0\n\t}\n\n\tmon := newMonitor(c.Meta, client, length)\n\treturn mon.monitor(resp.EvalID)\n}\n\nfunc parseFromSubmission(sub *api.JobSubmission) (*api.Job, error) {\n\tvar job *api.Job\n\tvar err error\n\n\tswitch sub.Format {\n\tcase \"hcl2\":\n\t\tjob, err = jobspec2.Parse(\"\", strings.NewReader(sub.Source))\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"Unable to parse job submission to re-enable scaling policies: %w\", err)\n\t\t}\n\n\tcase \"json\":\n\t\terr = json.Unmarshal([]byte(sub.Source), &job)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"Unable to parse job submission to re-enable scaling policies: %w\", err)\n\t\t}\n\t}\n\n\treturn job, nil\n}\n","sourceCodeStart":183,"sourceCodeEnd":213,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/job_start.go#L183-L213","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before (HCL1-style submission stored, parsed as hcl2)\njob \"web\" {\n  task \"server\" { driver = \"docker\" }\n}\n// after (valid HCL2)\njob \"web\" {\n  group \"web\" {\n    task \"server\" {\n      driver = \"docker\"\n    }\n  }\n}","handlingStrategy":"validation","validationCode":"# validate HCL2 before submitting\nnomad job run -output job.hcl > /dev/null || echo \"HCL2 parse failed\"","typeGuard":"func parsesAsHCL2(src string) error {\n    _, err := jobspec2.Parse(\"\", strings.NewReader(src))\n    return err // nil means valid\n}","tryCatchPattern":"job, err := parseFromSubmission(sub)\nif err != nil {\n    if strings.Contains(err.Error(), \"Failed to parse\") {\n        // surface the HCL diagnostic line to the user\n    }\n    return err\n}","preventionTips":["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."],"tags":["nomad","cli","hcl","parsing"],"backgroundTag":"hcl-parse-failed","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}