hashicorp/nomad · error
Must specify a destination for the template
Error message
Must specify a destination for the template
What it means
Template.Validate() requires a destination path where the rendered template will be written inside the allocation directory. When DestPath is empty, validation appends this error. Nomad cannot render a template without knowing where to place its output.
Source
Thrown at nomad/structs/structs.go:8969
}
func (t *Template) Canonicalize() {
if t.ChangeSignal != "" {
t.ChangeSignal = strings.ToUpper(t.ChangeSignal)
}
}
func (t *Template) Validate() error {
var mErr multierror.Error
// Verify we have something to render
if t.SourcePath == "" && t.EmbeddedTmpl == "" {
_ = multierror.Append(&mErr, fmt.Errorf("Must specify a source path or have an embedded template"))
}
// Verify we can render somewhere
if t.DestPath == "" {
_ = multierror.Append(&mErr, fmt.Errorf("Must specify a destination for the template"))
}
// Verify the destination doesn't escape
escaped, err := escapingfs.PathEscapesAllocViaRelative("task", t.DestPath)
if err != nil {
mErr.Errors = append(mErr.Errors, fmt.Errorf("invalid destination path: %v", err))
} else if escaped {
mErr.Errors = append(mErr.Errors, fmt.Errorf("destination escapes allocation directory"))
}
// Verify a proper change mode
switch t.ChangeMode {
case TemplateChangeModeNoop, TemplateChangeModeRestart:
case TemplateChangeModeSignal:
if t.ChangeSignal == "" {
_ = multierror.Append(&mErr, fmt.Errorf("Must specify signal value when change mode is signal"))
}
if t.Envvars {View on GitHub (pinned to 482b49bf1a)
Solutions
- Add `destination = "local/<file>"` to the template stanza (typically under local/ in the alloc dir).
- Re-run `nomad job validate` to confirm the template now passes.
- Check that job-generation tooling always sets destination.
Example fix
// before
template {
data = "key: value"
}
// after
template {
data = "key: value"
destination = "local/config.yml"
} Defensive patterns
Strategy: validation
Validate before calling
// Pre-submit check
if tpl.Destination == "" {
return errors.New("template requires a destination, e.g. local/app.conf")
} Prevention
- Adopt the convention destination = "local/<filename>" for every template.
- Never rely on a default destination — Nomad has none.
- Lint job HCL for template stanzas missing destination.
When it happens
Trigger: Submitting a job with template { source = "x.tpl" } (or data) but no `destination` field. Triggered when t.DestPath == "" in Template.Validate().
Common situations: Forgot the destination line; templating tooling omitted it; assuming Nomad writes next to the source by default (it does not — destination is mandatory).
Related errors
- Must specify a source path or have an embedded template
- Must specify signal value when change mode is signal
- template source path escapes alloc directory
- template destination path escapes alloc directory
- Invalid change mode. Must be one of the following: noop, sig
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/c1c98e0bc5dd8f1e.
Report an issue: GitHub.