{"record":{"id":"9b197b440ca13479","repo":"hashicorp/nomad","slug":"variable-requires-path","errorCode":null,"errorMessage":"variable requires path","messagePattern":"variable requires path","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/variables.go","lineNumber":415,"sourceCode":"\tif vd.Namespace == AllNamespacesSentinel {\n\t\tmErr.Errors = append(mErr.Errors, errWildCardNamespace)\n\t\treturn &mErr\n\t}\n\n\tif vd.Items.Size() > maxVariableSize {\n\t\treturn errQuotaExhausted\n\t}\n\n\tif err := ValidatePath(vd.Path); err != nil {\n\t\treturn err\n\t}\n\n\treturn vd.Lock.Validate()\n}\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\":","sourceCodeStart":397,"sourceCodeEnd":433,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/variables.go#L397-L433","documentation":"ValidatePath found an empty variable path. Every Nomad variable is addressed by a path, so VariableData.Validate fails immediately before the regex check when path is the empty string.","triggerScenarios":"Thrown at nomad/structs/variables.go:415 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Supply a path such as \"my/app/config\" when creating or updating the variable","Check the client SDK call is not dropping the path field"],"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-08T15:18:49.778Z"}