{"record":{"id":"461f5f8c9ce16c89","repo":"hashicorp/nomad","slug":"nomad-is-a-reserved-top-level-directory-path-bu","errorCode":null,"errorMessage":"\"nomad\" is a reserved top-level directory path, but you may write variables to \"nomad/jobs\", \"nomad/job-templates\", \"nomad/sentinel\", or below","messagePattern":"\"nomad\" is a reserved top-level directory path, but you may write variables to \"nomad/jobs\", \"nomad/job-templates\", \"nomad/sentinel\", or below","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/variables.go","lineNumber":429,"sourceCode":"}\n\nfunc ValidatePath(path string) error {\n\tif len(path) == 0 {\n\t\treturn fmt.Errorf(\"variable requires path\")\n\t}\n\tif !validVariablePath.MatchString(path) {\n\t\treturn fmt.Errorf(\"invalid path %q\", path)\n\t}\n\n\tparts := strings.Split(path, \"/\")\n\n\tif parts[0] != \"nomad\" {\n\t\treturn nil\n\t}\n\n\t// Don't allow a variable with path \"nomad\"\n\tif len(parts) == 1 {\n\t\treturn 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`)\n\t}\n\n\tswitch {\n\tcase parts[1] == \"jobs\" || parts[1] == \"sentinel\":\n\t\t// Any path including \"nomad/jobs\" or \"nomad/sentinel\" is valid\n\t\treturn nil\n\tcase parts[1] == \"job-templates\" && len(parts) == 3:\n\t\t// Paths including \"nomad/job-templates\" is valid, provided they have single further path part\n\t\treturn nil\n\tcase parts[1] == \"job-templates\":\n\t\t// Disallow exactly nomad/job-templates with no further paths\n\t\treturn 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\\\"\")\n\tdefault:\n\t\t// Disallow arbitrary sub-paths beneath nomad/\n\t\treturn fmt.Errorf(\"only paths at \\\"nomad/jobs\\\" or \\\"nomad/job-templates\\\" and below are valid paths under the top-level \\\"nomad\\\" directory\")\n\t}\n}\n","sourceCodeStart":411,"sourceCodeEnd":447,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/variables.go#L411-L447","documentation":"ValidatePath rejects a variable path of exactly \"nomad\": that top-level directory is reserved. Variables may be written under nomad/jobs, nomad/job-templates, nomad/sentinel, or deeper subpaths, but not at the root.","triggerScenarios":"Thrown at nomad/structs/variables.go:429 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Write the variable under \"nomad/jobs/...\" or another allowed subdirectory","Choose a non-reserved top-level path outside the nomad namespace"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}