{"record":{"id":"95023ac07b9411c3","repo":"lima-vm/lima","slug":"field-provision-d-owner-can-only-be-set-when-m","errorCode":null,"errorMessage":"field `provision[%d].owner` can only be set when mode is %#q","messagePattern":"field `provision\\[(.+?)\\]\\.owner` can only be set when mode is %#q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/limayaml/validate.go","lineNumber":246,"sourceCode":"\t\t\tif p.Mode == limatype.ProvisionModeYQ && p.Expression == nil {\n\t\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `provision[%d].expression` must not be empty when mode is %#q\", i, p.Mode))\n\t\t\t}\n\t\t\t// FillDefaults makes sure that p.Permissions is not nil\n\t\t\tif _, err := strconv.ParseInt(*p.Permissions, 8, 64); err != nil {\n\t\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `provision[%d].permissions` must be an octal number: %w\", i, err))\n\t\t\t}\n\t\tdefault:\n\t\t\tif (p.Script == nil || *p.Script == \"\") && p.Mode != limatype.ProvisionModeAnsible {\n\t\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `provision[%d].script` must not be empty\", i))\n\t\t\t}\n\t\t\tif p.Content != nil {\n\t\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `provision[%d].content` can only be set when mode is %#q\", i, limatype.ProvisionModeData))\n\t\t\t}\n\t\t\tif p.Overwrite != nil {\n\t\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `provision[%d].overwrite` can only be set when mode is %#q\", i, limatype.ProvisionModeData))\n\t\t\t}\n\t\t\tif p.Owner != nil {\n\t\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `provision[%d].owner` can only be set when mode is %#q\", i, limatype.ProvisionModeData))\n\t\t\t}\n\t\t\tif p.Path != nil {\n\t\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `provision[%d].path` can only be set when mode is %#q, or %#q\", i, limatype.ProvisionModeData, limatype.ProvisionModeYQ))\n\t\t\t}\n\t\t\tif p.Permissions != nil {\n\t\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `provision[%d].permissions` can only be set when mode is %#q, or %#q\", i, limatype.ProvisionModeData, limatype.ProvisionModeYQ))\n\t\t\t}\n\t\t\tif p.Format != nil {\n\t\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `provision[%d].format` can only be set when mode is %#q\", i, limatype.ProvisionModeYQ))\n\t\t\t}\n\t\t}\n\t\tif p.Playbook != \"\" {\n\t\t\tif p.Mode != limatype.ProvisionModeAnsible {\n\t\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `provision[%d].playbook can only be set when mode is %#q\", i, limatype.ProvisionModeAnsible))\n\t\t\t}\n\t\t\tif p.Script != nil && *p.Script != \"\" {\n\t\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `provision[%d].script must be empty if playbook is set\", i))\n\t\t\t}","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/limayaml/validate.go#L228-L264","documentation":"`owner` specifies the user that owns a file written by a data-mode provision entry, so it is only valid when `mode` is \"data\". Validate() rejects `owner` on any other mode to prevent silently ignored fields. The rendered message names `\"data\"` as the allowed mode.","triggerScenarios":"A provision entry with mode system/user/boot/dependency/ansible/yq (or unset) that sets `owner`, during create/start/restart/edit/apply/template validation.","commonSituations":"Wanting a script to run as root and mistakenly using `owner` (scripts have their own run-as semantics via mode); copying data-entry fields into script entries; templating that emits owner globally.","solutions":["Add `mode: data` (plus `path`/`content`) if you need `owner` for a written file","Delete the `owner` field from the non-data entry","Use `sudo`/`chown` inside a `script` entry instead of `owner`"],"exampleFix":"# before\nprovision:\n  - mode: user\n    owner: root\n    script: echo hi\n# after\nprovision:\n  - mode: user\n    script: echo hi\n# or, if ownership of a file is needed:\n# provision:\n#   - mode: data\n#     path: /etc/file\n#     content: hi\n#     owner: root","handlingStrategy":"validation","validationCode":"// Go: owner is data-mode only\nfor i, p := range cfg.Provision {\n    mode := limatype.ProvisionModeSystem\n    if p.Mode != nil { mode = *p.Mode }\n    if p.Owner != nil && mode != limatype.ProvisionModeData {\n        return fmt.Errorf(\"provision[%d]: owner requires mode data\", i)\n    }\n}","typeGuard":"func ownerAllowed(p limatype.Provision) bool {\n    return p.Owner == nil || (p.Mode != nil && *p.Mode == limatype.ProvisionModeData)\n}","tryCatchPattern":null,"preventionTips":["Use owner only on data entries that write files","For running scripts as another user, use sudo/chown inside the script","Keep a mode/field cheat sheet in template docs"],"tags":["lima","config-validation","provision","mode-mismatch"],"backgroundTag":"invalid-field-combination","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}