{"record":{"id":"57194fcec4444997","repo":"lima-vm/lima","slug":"field-provision-d-content-can-only-be-set-when","errorCode":null,"errorMessage":"field `provision[%d].content` can only be set when mode is %#q","messagePattern":"field `provision\\[(.+?)\\]\\.content` can only be set when mode is %#q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/limayaml/validate.go","lineNumber":240,"sourceCode":"\t\t\tif !path.IsAbs(*p.Path) {\n\t\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `provision[%d].path` must be an absolute path\", i))\n\t\t\t}\n\t\t\tif p.Mode == limatype.ProvisionModeData && p.Content == nil {\n\t\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `provision[%d].content` must not be empty when mode is %#q\", i, p.Mode))\n\t\t\t}\n\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 != \"\" {","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/limayaml/validate.go#L222-L258","documentation":"`content` is only meaningful for `mode: data` provision entries, where it provides the file body written to `path`. For script modes (system/user/boot/dependency/ansible) or yq mode, setting `content` is invalid; Validate() rejects it so silent misconfiguration cannot happen. The `%#q` in the message renders as `\"data\"`.","triggerScenarios":"A provision entry with mode system/user/boot/dependency/ansible (or default/empty mode) that also sets `content`, during create/start/restart/edit/apply/template validation.","commonSituations":"Authoring a file-write entry but forgetting `mode: data`; converting a data entry to a script and leaving content behind; template generators emitting content unconditionally.","solutions":["Add `mode: data` if the entry should write `content` to `path`","Otherwise delete the `content` field and keep/restore `script`","If you want both a file and a script, use two separate provision entries"],"exampleFix":"# before\nprovision:\n  - mode: user\n    content: |\n      hello\n# after\nprovision:\n  - mode: data\n    path: /etc/motd\n    content: |\n      hello","handlingStrategy":"validation","validationCode":"// Go: content 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.Content != nil && mode != limatype.ProvisionModeData {\n        return fmt.Errorf(\"provision[%d]: content requires mode data\", i)\n    }\n}","typeGuard":"func contentAllowed(p limatype.Provision) bool {\n    return p.Content == nil || (p.Mode != nil && *p.Mode == limatype.ProvisionModeData)\n}","tryCatchPattern":null,"preventionTips":["Remember field-to-mode mapping: content/overwrite/owner -> data; path/permissions -> data+yq; format -> yq; playbook -> ansible","Split entries that need both a file and a script into two provisions","Validate configs in CI with `limactl validate`"],"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"}