{"record":{"id":"000fab0e518bbfa9","repo":"hashicorp/nomad","slug":"command-is-required-but-was-empty","errorCode":null,"errorMessage":"command is required but was empty","messagePattern":"command is required but was empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/docker/driver.go","lineNumber":1944,"sourceCode":"\treturn h.Exec(ctx, cmd[0], cmd[1:])\n}\n\nvar _ drivers.ExecTaskStreamingDriver = (*Driver)(nil)\n\nfunc (d *Driver) ExecTaskStreaming(ctx context.Context, taskID string, opts *drivers.ExecOptions) (*drivers.ExitResult, error) {\n\tdefer opts.Stdout.Close()\n\tdefer opts.Stderr.Close()\n\n\tdone := make(chan interface{})\n\tdefer close(done)\n\n\th, ok := d.tasks.Get(taskID)\n\tif !ok {\n\t\treturn nil, drivers.ErrTaskNotFound\n\t}\n\n\tif len(opts.Command) == 0 {\n\t\treturn nil, fmt.Errorf(\"command is required but was empty\")\n\t}\n\n\tcreateExecOpts := mclient.ExecCreateOptions{\n\t\tAttachStdin:  true,\n\t\tAttachStdout: true,\n\t\tAttachStderr: true,\n\t\tTTY:          opts.Tty,\n\t\tCmd:          opts.Command,\n\t}\n\n\tclient, err := d.getDockerClient()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\texec, err := client.ExecCreate(d.ctx, h.containerID, createExecOpts)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create exec object: %v\", err)","sourceCodeStart":1926,"sourceCodeEnd":1962,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/docker/driver.go#L1926-L1962","documentation":"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.","triggerScenarios":"Calling driver.ExecTaskStreaming with an ExecOptions whose Command field is empty or unset.","commonSituations":"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.","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."],"exampleFix":"// before\nopts := drivers.ExecOptions{Command: \"\", Arguments: []string{\"-c\", \"date\"}}\n// after\nopts := drivers.ExecOptions{Command: \"/bin/sh\", Arguments: []string{\"-c\", \"date\"}}","handlingStrategy":"validation","validationCode":"if opts.Command == \"\" { return errors.New(\"opts.Command is required for exec\") }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["docker","exec","validation"],"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"}