kubernetes/kops · error
cannot parse file mode %q
Error message
cannot parse file mode %q
What it means
Thrown by ParseFileMode when the provided string is non-empty but not a valid octal number (parsed with strconv.ParseUint base 8). The mode string is typically user-supplied config, e.g. a file mode like "0644"; values like "644 " (non-octal chars), "0999" (invalid octal digit), or "rw-r--r--" trigger this.
Source
Thrown at upup/pkg/fi/files.go:149
return false, nil
}
return false, err
}
if actual.Equal(expected) {
klog.V(2).Infof("Hash matched for %q: %v", f, expected)
return true, nil
}
klog.V(2).Infof("Hash did not match for %q: actual=%v vs expected=%v", f, actual, expected)
return false, nil
}
func ParseFileMode(s string, defaultMode os.FileMode) (os.FileMode, error) {
fileMode := defaultMode
if s != "" {
v, err := strconv.ParseUint(s, 8, 32)
if err != nil {
return fileMode, fmt.Errorf("cannot parse file mode %q", s)
}
fileMode = os.FileMode(v)
}
return fileMode, nil
}
func FileModeToString(mode os.FileMode) string {
return "0" + strconv.FormatUint(uint64(mode), 8)
}
func SafeClose(r io.Reader) {
if r == nil {
return
}
closer, ok := r.(io.Closer)
if !ok {
return
}View on GitHub (pinned to 4c8573c808)
Solutions
- Use a valid octal mode string such as "0644" or "0755"
- Remove stray characters, spaces, or symbolic notation like rw-r--r-- from the mode value
- Locate the config field (e.g. file mode in the spec or asset config) that carried the bad string
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at upup/pkg/fi/files.go:149 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/57dd6cddc11a71b2.
Report an issue: GitHub.