hashicorp/nomad · error
command contains extra white space: %q
Error message
command contains extra white space: %q
What it means
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.
Source
Thrown at drivers/docker/driver.go:1743
// be caused by races between listing
// containers and this container being removed.
// See #2802
return nil, nstructs.NewRecoverableError(err, true)
}
return &container, nil
}
// validateCommand validates that the command only has a single value and
// returns a user friendly error message telling them to use the passed
// argField.
func validateCommand(command, argField string) error {
trimmed := strings.TrimSpace(command)
if len(trimmed) == 0 {
return fmt.Errorf("command empty: %q", command)
}
if len(trimmed) != len(command) {
return fmt.Errorf("command contains extra white space: %q", command)
}
return nil
}
func (d *Driver) WaitTask(ctx context.Context, taskID string) (<-chan *drivers.ExitResult, error) {
h, ok := d.tasks.Get(taskID)
if !ok {
return nil, drivers.ErrTaskNotFound
}
ch := make(chan *drivers.ExitResult)
go d.handleWait(ctx, ch, h)
return ch, nil
}
func (d *Driver) handleWait(ctx context.Context, ch chan *drivers.ExitResult, h *taskHandle) {
defer close(ch)
select {View on GitHub (pinned to 482b49bf1a)
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.
Example fix
// before
config {
entrypoint = "/bin/myapp --flag"
}
// after
config {
entrypoint = "/bin/myapp"
args = ["--flag"]
} Defensive patterns
Strategy: validation
Validate before calling
func isSingleToken(v string) bool { return strings.TrimSpace(v) != "" && strings.TrimSpace(v) == v }
// reject before submit if extra whitespace detected Prevention
- 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
When it happens
Trigger: 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).
Common situations: HCL templates injecting trailing newlines, users putting multiple words into the single-value field instead of args, copy-paste with trailing whitespace.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- does not match registry specification
- invalid cgroup permission string: %q
- invalid mount type, must be "bind", "volume", "tmpfs": %q
- command empty: %q
- missing secret ID
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/784343b7c54d1a9f.
Report an issue: GitHub.