hashicorp/nomad · error

"nomad/job-templates" is a reserved directory path, but you

Error message

"nomad/job-templates" is a reserved directory path, but you may write variables at the level below it, for example, "nomad/job-templates/template-name"

What it means

ValidatePath guard: the path is exactly "nomad/job-templates" or otherwise not one level deeper. Job templates are addressed as nomad/job-templates/<template-name>, with exactly one further path part.

Source

Thrown at nomad/structs/variables.go:441

	if parts[0] != "nomad" {
		return nil
	}

	// Don't allow a variable with path "nomad"
	if len(parts) == 1 {
		return fmt.Errorf(`"nomad" is a reserved top-level directory path, but you may write variables to "nomad/jobs", "nomad/job-templates", "nomad/sentinel", or below`)
	}

	switch {
	case parts[1] == "jobs" || parts[1] == "sentinel":
		// Any path including "nomad/jobs" or "nomad/sentinel" is valid
		return nil
	case parts[1] == "job-templates" && len(parts) == 3:
		// Paths including "nomad/job-templates" is valid, provided they have single further path part
		return nil
	case parts[1] == "job-templates":
		// Disallow exactly nomad/job-templates with no further paths
		return fmt.Errorf("\"nomad/job-templates\" is a reserved directory path, but you may write variables at the level below it, for example, \"nomad/job-templates/template-name\"")
	default:
		// Disallow arbitrary sub-paths beneath nomad/
		return fmt.Errorf("only paths at \"nomad/jobs\" or \"nomad/job-templates\" and below are valid paths under the top-level \"nomad\" directory")
	}
}

func (vd *VariableDecrypted) Canonicalize() {
	if vd.Namespace == "" {
		vd.Namespace = DefaultNamespace
	}

	if vd.Lock != nil {
		vd.Lock.Canonicalize()
	}
}

// Copy returns a fully hydrated copy of VariableMetadata that can be
// manipulated while ensuring the original is not touched.

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Append the template name, e.g. "nomad/job-templates/my-template"
  2. Use exactly one additional path segment below nomad/job-templates
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at nomad/structs/variables.go:441 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/e0d7353a33e0ad45. Report an issue: GitHub.