{"record":{"id":"4c82f5219ebf1237","repo":"hashicorp/nomad","slug":"failed-reading-template-contents-w","errorCode":null,"errorMessage":"failed reading template contents: %w","messagePattern":"failed reading template contents: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/allocrunner/taskrunner/template/renderer/z_template_render.go","lineNumber":115,"sourceCode":"func writeTemplate() (*renderer.RenderResult, error) {\n\n\tvar (\n\t\tsandboxPath, destPath, perms, user, group string\n\t)\n\n\tflags := flag.NewFlagSet(\"template-render\", flag.ExitOnError)\n\tflags.StringVar(&sandboxPath, \"sandbox-path\", \"\", \"\")\n\tflags.StringVar(&destPath, \"dest-path\", \"\", \"\")\n\tflags.StringVar(&perms, \"perms\", \"\", \"\")\n\tflags.StringVar(&user, \"user\", \"\", \"\")\n\tflags.StringVar(&group, \"group\", \"\", \"\")\n\n\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 {","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/allocrunner/taskrunner/template/renderer/z_template_render.go#L97-L133","documentation":"In the template-render child process, writeTemplate failed reading the rendered template contents piped on stdin (io.Copy from os.Stdin), so the destination file cannot be written and rendering aborts.","triggerScenarios":"Thrown at client/allocrunner/taskrunner/template/renderer/z_template_render.go:115 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check parent process logs for the error passing template contents","Verify pipe/stdio is intact for the subprocess","Retry the template render; check system resource limits"],"exampleFix":null,"handlingStrategy":"retry","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"}