{"record":{"id":"645f82a4c2d8ad4a","repo":"hashicorp/nomad","slug":"command-empty-q","errorCode":null,"errorMessage":"command empty: %q","messagePattern":"command empty: %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/docker/driver.go","lineNumber":1739,"sourceCode":"\tif err != nil {\n\t\terr = fmt.Errorf(\"Failed to inspect container %s: %s\", shimContainer.ID, err)\n\n\t\t// This error is always recoverable as it could\n\t\t// be caused by races between listing\n\t\t// containers and this container being removed.\n\t\t// See #2802\n\t\treturn nil, nstructs.NewRecoverableError(err, true)\n\t}\n\treturn &container, nil\n}\n\n// validateCommand validates that the command only has a single value and\n// returns a user friendly error message telling them to use the passed\n// argField.\nfunc validateCommand(command, argField string) error {\n\ttrimmed := strings.TrimSpace(command)\n\tif len(trimmed) == 0 {\n\t\treturn fmt.Errorf(\"command empty: %q\", command)\n\t}\n\n\tif len(trimmed) != len(command) {\n\t\treturn fmt.Errorf(\"command contains extra white space: %q\", command)\n\t}\n\n\treturn nil\n}\n\nfunc (d *Driver) WaitTask(ctx context.Context, taskID string) (<-chan *drivers.ExitResult, error) {\n\th, ok := d.tasks.Get(taskID)\n\tif !ok {\n\t\treturn nil, drivers.ErrTaskNotFound\n\t}\n\tch := make(chan *drivers.ExitResult)\n\tgo d.handleWait(ctx, ch, h)\n\treturn ch, nil\n}","sourceCodeStart":1721,"sourceCodeEnd":1757,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/docker/driver.go#L1721-L1757","documentation":"validateCommand is a helper that rejects an empty command string passed to config fields that expect a single token (e.g. the entrypoint field), pointing the user to the companion args field. An all-whitespace command also triggers it because TrimSpace empties it.","triggerScenarios":"A task sets a driver config field like `entrypoint = \"\"` (or only whitespace) while validateCommand checks it; StartTask fails during container config creation.","commonSituations":"Templated job files where a variable renders empty, users mistaking entrypoint for the full command list, copy-paste removing the value.","solutions":["Provide a non-empty command value in the driver config field.","Move the actual command/arguments into the args field instead of the single-token field.","Fix the template/variable so it renders a real value; or remove the field entirely to use the image default."],"exampleFix":"// before\nconfig {\n  entrypoint = \"\"\n}\n// after\nconfig {\n  entrypoint = \"/bin/myapp\"\n  args = [\"--port\", \"8080\"]\n}","handlingStrategy":"validation","validationCode":"func commandPresent(v string) bool { return strings.TrimSpace(v) != \"\" }\n// in CI: fail job registration if entrypoint/command fields are empty strings","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never pass empty strings for single-token driver fields; omit the field instead","Check rendered templates for empty variables before nomad job run","Put multi-word commands in args, not the single command/entrypoint field"],"tags":["docker","nomad","validation","empty-argument"],"backgroundTag":"empty-required-field","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"}