{"record":{"id":"259027487fab9806","repo":"hashicorp/nomad","slug":"command-cannot-be-empty","errorCode":null,"errorMessage":"command cannot be empty","messagePattern":"command cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/actions.go","lineNumber":86,"sourceCode":"\tif a == nil && o == nil {\n\t\treturn true\n\t}\n\tif a == nil || o == nil {\n\t\treturn false\n\t}\n\treturn a.Name == o.Name &&\n\t\ta.Command == o.Command &&\n\t\tslices.Equal(a.Args, o.Args)\n}\n\nfunc (a *Action) Validate() error {\n\tif a == nil {\n\t\treturn nil\n\t}\n\n\tvar mErr *multierror.Error\n\tif a.Command == \"\" {\n\t\tmErr = multierror.Append(mErr, errors.New(\"command cannot be empty\"))\n\t}\n\tif !validJobActionName.MatchString(a.Name) {\n\t\tmErr = multierror.Append(mErr, fmt.Errorf(\"invalid name '%s'\", a.Name))\n\t}\n\n\treturn mErr.ErrorOrNil()\n}\n","sourceCodeStart":68,"sourceCodeEnd":94,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/actions.go#L68-L94","documentation":"JobAction.Validate() in nomad/structs/actions.go validates a job action definition. Every action must have a Command, so an empty Command field produces \"command cannot be empty\". The check exists because an action without a command has no executable semantics and would be unusable at runtime.","triggerScenarios":"Submitting a job (jobs parse/validate path) whose task group or task defines an `action` block with a name but no `command` attribute, e.g. HCL `action \"shell\" {}` or an equivalent JobAction struct with Command: \"\".","commonSituations":"Hand-writing HCL job files and omitting the command line; templating that renders an empty command from missing variables; upgrading Nomad where actions became stricter.","solutions":["Add a non-empty `command` to the action block in the job spec (e.g. `command = \"/bin/sh\"` with args).","If the command is templated, check the rendered job file (nomad job inspect / plan) to confirm the variable resolved.","Validate the JobAction struct client-side before submission: if a.Command == \"\" reject early with a clearer message."],"exampleFix":"// HCL before\naction \"debug\" {\n  args = [\"-c\", \"ps aux\"]\n}\n\n// HCL after\naction \"debug\" {\n  command = \"/bin/sh\"\n  args    = [\"-c\", \"ps aux\"]\n}","handlingStrategy":"validation","validationCode":"if action.Command == \"\" {\n    return fmt.Errorf(\"action %q requires a command\", action.Name)\n}","typeGuard":null,"tryCatchPattern":"if _, err := jobs.Validate(); err != nil {\n    if strings.Contains(err.Error(), \"command cannot be empty\") {\n        return fmt.Errorf(\"an action block in the jobspec is missing its command\")\n    }\n    return err\n}","preventionTips":["Always include both command and args in every action block in HCL.","Run `nomad job validate <file>` before submitting templated jobs.","Inspect rendered templates to ensure variables feeding `command` resolved to non-empty values."],"tags":["nomad","validation","jobspec","actions"],"backgroundTag":"missing-required-argument","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"}