{"record":{"id":"4164f8525fc56657","repo":"hashicorp/nomad","slug":"invalid-path-q","errorCode":null,"errorMessage":"invalid path %q","messagePattern":"invalid path %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/variables.go","lineNumber":418,"sourceCode":"\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\":\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:","sourceCodeStart":400,"sourceCodeEnd":436,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/variables.go#L400-L436","documentation":"ValidatePath guard: the variable path fails the validVariablePath regex — it contains characters or shapes not permitted in variable paths (e.g. invalid segments). The offending path is quoted in the message.","triggerScenarios":"Thrown at nomad/structs/variables.go:418 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use only path-safe characters and slash-separated segments","Avoid empty segments (double slashes) and invalid characters in the path"],"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"}