hashicorp/nomad · error
Invalid file mode %q: Must be a valid octal number: %w
Error message
Invalid file mode %q: Must be a valid octal number: %w
What it means
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.
Source
Thrown at client/allocrunner/taskrunner/template/renderer/z_template_render.go:128
flags.Parse(os.Args[3:])
contents := new(bytes.Buffer)
_, err := io.Copy(contents, os.Stdin)
if err != nil {
return nil, fmt.Errorf("failed reading template contents: %w", err)
}
destPath, err = sandbox(sandboxPath, destPath) // platform-specific sandboxing
if err != nil {
return nil, fmt.Errorf("failed to sandbox alloc dir %q: %w", sandboxPath, err)
}
// perms must parse into a valid file permission
fileMode := os.FileMode(DefaultFilePerms)
if perms != "" {
fileModeInt, err := strconv.ParseUint(perms, 8, 32)
if err != nil {
return nil, fmt.Errorf(
"Invalid file mode %q: Must be a valid octal number: %w", perms, err)
}
fileMode = fs.FileMode(fileModeInt)
if fileMode.Perm() != fileMode {
return nil, fmt.Errorf(
"Invalid file mode %q: Must be a valid Unix permission: %w", perms, err)
}
}
input := &renderer.RenderInput{
Backup: false,
Contents: contents.Bytes(),
CreateDestDirs: true,
Dry: false,
DryStream: nil,
Path: destPath,
Perms: fileMode,View on GitHub (pinned to 482b49bf1a)
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at client/allocrunner/taskrunner/template/renderer/z_template_render.go:128 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/5bff47f1af5a28e1.
Report an issue: GitHub.