{"record":{"id":"5bff47f1af5a28e1","repo":"hashicorp/nomad","slug":"invalid-file-mode-q-must-be-a-valid-octal-number","errorCode":null,"errorMessage":"Invalid file mode %q: Must be a valid octal number: %w","messagePattern":"Invalid file mode %q: Must be a valid octal number: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/allocrunner/taskrunner/template/renderer/z_template_render.go","lineNumber":128,"sourceCode":"\tflags.Parse(os.Args[3:])\n\n\tcontents := new(bytes.Buffer)\n\t_, err := io.Copy(contents, os.Stdin)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed reading template contents: %w\", err)\n\t}\n\n\tdestPath, err = sandbox(sandboxPath, destPath) // platform-specific sandboxing\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to sandbox alloc dir %q: %w\", sandboxPath, err)\n\t}\n\n\t// perms must parse into a valid file permission\n\tfileMode := os.FileMode(DefaultFilePerms)\n\tif perms != \"\" {\n\t\tfileModeInt, err := strconv.ParseUint(perms, 8, 32)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\n\t\t\t\t\"Invalid file mode %q: Must be a valid octal number: %w\", perms, err)\n\n\t\t}\n\t\tfileMode = fs.FileMode(fileModeInt)\n\t\tif fileMode.Perm() != fileMode {\n\t\t\treturn nil, fmt.Errorf(\n\t\t\t\t\"Invalid file mode %q: Must be a valid Unix permission: %w\", perms, err)\n\t\t}\n\t}\n\n\tinput := &renderer.RenderInput{\n\t\tBackup:         false,\n\t\tContents:       contents.Bytes(),\n\t\tCreateDestDirs: true,\n\t\tDry:            false,\n\t\tDryStream:      nil,\n\t\tPath:           destPath,\n\t\tPerms:          fileMode,","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/allocrunner/taskrunner/template/renderer/z_template_render.go#L110-L146","documentation":"writeTemplate validation guard: the perms argument passed to the template-render subprocess is not a valid octal number, so strconv.ParseUint(perms, 8, 32) fails and the destination file mode cannot be established.","triggerScenarios":"Thrown at client/allocrunner/taskrunner/template/renderer/z_template_render.go:128 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set a valid octal file permission in the template's perms field (e.g. 0644)","Check the client version supports the perms field syntax"],"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"}