{"record":{"id":"eeb464c4a5f65868","repo":"lima-vm/lima","slug":"field-provision-d-path-can-only-be-set-when-mo","errorCode":null,"errorMessage":"field `provision[%d].path` can only be set when mode is %#q, or %#q","messagePattern":"field `provision\\[(.+?)\\]\\.path` can only be set when mode is %#q, or %#q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/limayaml/validate.go","lineNumber":249,"sourceCode":"\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}\n\t\t\tplaybook := p.Playbook\n\t\t\tif _, err := os.Stat(playbook); err != nil {\n\t\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `provision[%d].playbook` refers to an inaccessible path: %#q: %w\", i, playbook, err))","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/limayaml/validate.go#L231-L267","documentation":"`path` names the target file for data-mode (file write) and yq-mode (YAML edit) provision entries only. Script modes do not take a target path, so Validate() rejects `path` on entries whose mode is neither \"data\" nor \"yq\". The rendered message lists `\"data\"` and `\"yq\"` as the allowed modes.","triggerScenarios":"A provision entry with mode system/user/boot/dependency/ansible (or unset) that sets `path`, during create/start/restart/edit/apply/template validation.","commonSituations":"Mixing data and script entry templates; leaving `path` on an entry after switching from data mode to a script; confusion with `playbook` (ansible) needing a path-like value — playbook is a separate field.","solutions":["Set `mode: data` or `mode: yq` if the entry targets a file at `path`","Delete the `path` field from script entries (use `script`/`playbook` instead)","For ansible, move the value to the `playbook` field"],"exampleFix":"# before\nprovision:\n  - mode: boot\n    path: /etc/rc.local\n    script: exit 0\n# after\nprovision:\n  - mode: boot\n    script: exit 0","handlingStrategy":"validation","validationCode":"// Go: path requires data or yq mode\nfor i, p := range cfg.Provision {\n    mode := limatype.ProvisionModeSystem\n    if p.Mode != nil { mode = *p.Mode }\n    if p.Path != nil && mode != limatype.ProvisionModeData && mode != limatype.ProvisionModeYQ {\n        return fmt.Errorf(\"provision[%d]: path requires mode data or yq\", i)\n    }\n}","typeGuard":"func pathAllowed(p limatype.Provision) bool {\n    if p.Path == nil { return true }\n    return p.Mode != nil && (*p.Mode == limatype.ProvisionModeData || *p.Mode == limatype.ProvisionModeYQ)\n}","tryCatchPattern":null,"preventionTips":["Set path only together with content (data) or expression (yq)","For ansible playbooks use `playbook`, not `path`","Validate configs after mode changes"],"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"}