{"record":{"id":"5c644d4331735316","repo":"lima-vm/lima","slug":"invalid-permissions-q-for-path-q-w","errorCode":null,"errorMessage":"invalid permissions %#q for path %#q: %w","messagePattern":"invalid permissions %#q for path %#q: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/guestagent/fakecloudinit/fakecloudinit_darwin.go","lineNumber":347,"sourceCode":"\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to open sudoers file %#q: %w\", sudoersPath, err)\n\t}\n\tif _, err = fmt.Fprintf(f, \"%s %s\\n\", userName, sudo); err != nil {\n\t\t_ = f.Close()\n\t\treturn fmt.Errorf(\"failed to write to sudoers file %#q for user %#q: %w\", sudoersPath, userName, err)\n\t}\n\treturn f.Close()\n}\n\nfunc writeFiles(ctx context.Context, entry cloudinittypes.WriteFile) error {\n\tif entry.Path == \"\" {\n\t\treturn errors.New(\"path is required for write_files entry\")\n\t}\n\tperm := os.FileMode(0o644)\n\tif entry.Permissions != \"\" {\n\t\tp, err := strconv.ParseUint(entry.Permissions, 8, 32)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid permissions %#q for path %#q: %w\", entry.Permissions, entry.Path, err)\n\t\t}\n\t\tperm = os.FileMode(p)\n\t}\n\tif err := os.MkdirAll(filepath.Dir(entry.Path), 0o755); err != nil {\n\t\treturn fmt.Errorf(\"failed to create parent directory for path %#q: %w\", entry.Path, err)\n\t}\n\tif err := os.WriteFile(entry.Path, []byte(entry.Content), perm); err != nil {\n\t\treturn fmt.Errorf(\"failed to write file for path %#q: %w\", entry.Path, err)\n\t}\n\tif entry.Owner != \"\" {\n\t\tcmd := exec.CommandContext(ctx, \"chown\", entry.Owner, entry.Path)\n\t\tlogrus.Infof(\"Executing command: %v\", cmd.Args)\n\t\tif output, err := cmd.CombinedOutput(); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to execute command %v: %w (output=%#q)\", cmd.Args, err, output)\n\t\t}\n\t}\n\treturn nil\n}","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/guestagent/fakecloudinit/fakecloudinit_darwin.go#L329-L365","documentation":"The fake cloud-init implementation for macOS hosts parses the `permissions` field of each `write_files` user-data entry as an octal number (e.g. \"0644\"). If `strconv.ParseUint(entry.Permissions, 8, 32)` fails, this error is thrown and provisioning of the user data aborts. It wraps the parse error, so the wrapped text names the exact invalid character.","triggerScenarios":"A write_files entry in the user-data consumed by the Lima macOS guestagent has a `permissions` string that is not a valid base-8 uint32, e.g. \"644\" with a typo like \"rwxr-xr-x\", \"0o644\", \"\", negative values, or values above 0777 with non-octal digits like 8 or 9.","commonSituations":"Copy-pasting Linux symbolic permission strings into cloud-init YAML; using the Go-style `0o644` prefix instead of plain `0644`; hand-editing templates and leaving a placeholder or comment in the permissions field.","solutions":["Fix the `permissions` field in the write_files entry to be a plain octal string such as \"0644\" or \"0600\".","Remove the `permissions` field entirely if the default 0644 is acceptable.","Check the wrapped parse error in the message to identify the offending character in the permissions string.","Validate the user-data YAML with a cloud-init schema checker before provisioning."],"exampleFix":"// before\npermissions: \"u=rw,go=r\"\n// after\npermissions: \"0644\"","handlingStrategy":"validation","validationCode":"for _, e := range userData.WriteFiles {\n    if e.Permissions != \"\" {\n        if _, err := strconv.ParseUint(e.Permissions, 8, 32); err != nil {\n            return fmt.Errorf(\"entry %s: invalid octal permissions %q\", e.Path, e.Permissions)\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := processUserData(ctx, data); err != nil {\n    var parseErr *strconv.NumError\n    if errors.As(err, &parseErr) {\n        // fix the permissions field reported in the message\n    }\n}","preventionTips":["Always write permissions as 3-4 digit octal strings (\"0644\", \"0600\").","Never use symbolic (rwx) or 0o-prefixed formats in cloud-init YAML.","Lint user-data YAML with a cloud-init schema validator before provisioning."],"tags":["cloud-init","macos","permissions","configuration"],"backgroundTag":"invalid-octal-permissions","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}