hashicorp/nomad · error
command is required but was empty
Error message
command is required but was empty
What it means
The streaming ExecTask variant validates that opts.Command (the binary to exec inside the container) is non-empty before building mclient.ExecCreateOptions. The driver refuses to create a Docker exec with no command, since the Docker API requires a cmd array. Like [1572], this is pre-flight input validation.
Source
Thrown at drivers/docker/driver.go:1944
return h.Exec(ctx, cmd[0], cmd[1:])
}
var _ drivers.ExecTaskStreamingDriver = (*Driver)(nil)
func (d *Driver) ExecTaskStreaming(ctx context.Context, taskID string, opts *drivers.ExecOptions) (*drivers.ExitResult, error) {
defer opts.Stdout.Close()
defer opts.Stderr.Close()
done := make(chan interface{})
defer close(done)
h, ok := d.tasks.Get(taskID)
if !ok {
return nil, drivers.ErrTaskNotFound
}
if len(opts.Command) == 0 {
return nil, fmt.Errorf("command is required but was empty")
}
createExecOpts := mclient.ExecCreateOptions{
AttachStdin: true,
AttachStdout: true,
AttachStderr: true,
TTY: opts.Tty,
Cmd: opts.Command,
}
client, err := d.getDockerClient()
if err != nil {
return nil, err
}
exec, err := client.ExecCreate(d.ctx, h.containerID, createExecOpts)
if err != nil {
return nil, fmt.Errorf("failed to create exec object: %v", err)View on GitHub (pinned to 482b49bf1a)
Solutions
- Set opts.Command to a non-empty value (e.g. "/bin/bash" or "/bin/sh").
- Provide Arguments separately for the command's parameters.
- Add caller-side validation before invoking ExecTaskStreaming.
Example fix
// before
opts := drivers.ExecOptions{Command: "", Arguments: []string{"-c", "date"}}
// after
opts := drivers.ExecOptions{Command: "/bin/sh", Arguments: []string{"-c", "date"}} Defensive patterns
Strategy: validation
Validate before calling
if opts.Command == "" { return errors.New("opts.Command is required for exec") } Prevention
- Set Command (binary) and Arguments separately and explicitly.
- Require the command in UI/tooling before allowing exec.
- Add a smoke test for streaming exec configuration.
When it happens
Trigger: Calling driver.ExecTaskStreaming with an ExecOptions whose Command field is empty or unset.
Common situations: UI/tool invoking streaming exec without a command prompt; template variables that expanded to an empty command; copying legacy code that only set Arguments but not Command.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- cmd is required, but was empty
- command is not present
- does not match registry specification
- unknown task name %q
- must provide task name
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/000fab0e518bbfa9.
Report an issue: GitHub.