{"record":{"id":"784343b7c54d1a9f","repo":"hashicorp/nomad","slug":"command-contains-extra-white-space-q","errorCode":null,"errorMessage":"command contains extra white space: %q","messagePattern":"command contains extra white space: %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/docker/driver.go","lineNumber":1743,"sourceCode":"\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}\n\nfunc (d *Driver) handleWait(ctx context.Context, ch chan *drivers.ExitResult, h *taskHandle) {\n\tdefer close(ch)\n\tselect {","sourceCodeStart":1725,"sourceCodeEnd":1761,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/docker/driver.go#L1725-L1761","documentation":"The same validateCommand helper rejects a command string with leading/trailing or extra internal whitespace, since only a single value is allowed in the target config field. The message directs users to the args field for multiple tokens.","triggerScenarios":"A config field like `entrypoint = \"/bin/app \"` or `\"/bin myapp\"` contains stray spaces or a trailing newline from templating, so len(TrimSpace(cmd)) != len(cmd).","commonSituations":"HCL templates injecting trailing newlines, users putting multiple words into the single-value field instead of args, copy-paste with trailing whitespace.","solutions":["Remove surrounding whitespace from the command value.","Split multiple tokens into the args field.","Render the template with trim (e.g. tmpl function or `trim()` in HCL) to strip stray newlines."],"exampleFix":"// before\nconfig {\n  entrypoint = \"/bin/myapp --flag\"\n}\n// after\nconfig {\n  entrypoint = \"/bin/myapp\"\n  args = [\"--flag\"]\n}","handlingStrategy":"validation","validationCode":"func isSingleToken(v string) bool { return strings.TrimSpace(v) != \"\" && strings.TrimSpace(v) == v }\n// reject before submit if extra whitespace detected","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Trim rendered templates (strings.TrimSpace / HCL trim functions) before injecting into driver fields","Split multi-word commands into args","Add a linter rule flagging whitespace in single-value driver config fields"],"tags":["docker","nomad","validation","whitespace"],"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"}