{"record":{"id":"7ce625b126d0ad6c","repo":"lima-vm/lima","slug":"path-is-required-for-write-files-entry","errorCode":null,"errorMessage":"path is required for write_files entry","messagePattern":"path is required for write_files entry","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/guestagent/fakecloudinit/fakecloudinit_darwin.go","lineNumber":341,"sourceCode":"\t}\n\tif err := os.MkdirAll(\"/etc/sudoers.d\", 0o700); err != nil {\n\t\treturn fmt.Errorf(\"failed to create /etc/sudoers.d directory: %w\", err)\n\t}\n\tsudoersPath := \"/etc/sudoers.d/90-cloud-init-users\"\n\tf, err := os.OpenFile(sudoersPath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0o400)\n\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)","sourceCodeStart":323,"sourceCodeEnd":359,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/guestagent/fakecloudinit/fakecloudinit_darwin.go#L323-L359","documentation":"A `write_files` cloud-init entry was supplied without the mandatory `path` field. fakecloudinit's writeFiles requires an absolute destination path before it can create parent directories and write content, so it fails fast with this validation error instead of guessing a location.","triggerScenarios":"processUserData iterates the user-data `write_files` list and an entry has `path: \"\"` or the field omitted. Also caused by YAML indentation mistakes that produce an entry object without a path key.","commonSituations":"Copy-pasted write_files entries missing `path`; wrong YAML indentation placing `path` outside the entry mapping; templating that leaves `${PATH}`-style placeholders unexpanded, yielding an empty value.","solutions":["Add a `path` (absolute) to every write_files entry in user-data","Fix YAML indentation so `path` is inside the same list item as `content`","Check template expansion did not leave the path empty","Validate the user-data YAML structure before starting the instance"],"exampleFix":"# before\nwrite_files:\n- content: |\n    hello\n# after\nwrite_files:\n- path: /etc/hello.conf\n  content: |\n    hello","handlingStrategy":"validation","validationCode":"func validateWriteFiles(entries []cloudinittypes.WriteFile) error {\n    for i, e := range entries {\n        if e.Path == \"\" {\n            return fmt.Errorf(\"write_files[%d]: path is required\", i)\n        }\n        if !filepath.IsAbs(e.Path) {\n            return fmt.Errorf(\"write_files[%d]: path %q must be absolute\", i, e.Path)\n        }\n    }\n    return nil\n}","typeGuard":"func hasPath(e cloudinittypes.WriteFile) bool {\n    return strings.TrimSpace(e.Path) != \"\"\n}","tryCatchPattern":"if err := processUserData(ctx, data); err != nil {\n    if strings.Contains(err.Error(), \"path is required for write_files\") {\n        log.Printf(\"user-data write_files entry missing path: %v\", err)\n    }\n}","preventionTips":["Always specify an absolute `path` for each write_files entry","Check YAML indentation so `path` sits inside the same list item","Validate user-data YAML (e.g. with yamllint or cloud-init schema tools) before starting the instance"],"tags":["validation","cloud-init","yaml","guestagent"],"backgroundTag":"missing-required-argument","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}