{"record":{"id":"3d5df6a46fc14a1f","repo":"lima-vm/lima","slug":"field-provision-d-format-can-only-be-set-when","errorCode":null,"errorMessage":"field `provision[%d].format` can only be set when mode is %#q","messagePattern":"field `provision\\[(.+?)\\]\\.format` can only be set when mode is %#q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/limayaml/validate.go","lineNumber":255,"sourceCode":"\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))\n\t\t\t}\n\t\t\tlogrus.Warnf(\"provision mode %#q is deprecated, use `ansible-playbook %#q` instead\", limatype.ProvisionModeAnsible, playbook)\n\t\t}\n\t\tif p.Script != nil {\n\t\t\tif strings.Contains(*p.Script, \"LIMA_CIDATA\") {\n\t\t\t\tlogrus.Warn(\"provisioning scripts should not reference the LIMA_CIDATA variables\")","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/limayaml/validate.go#L237-L273","documentation":"`format` specifies the input format (e.g. yaml/json) of the target for a yq-mode provision entry, so it is only valid when `mode` is \"yq\". Validate() rejects `format` on every other mode. The rendered message names `\"yq\"` as the allowed mode.","triggerScenarios":"A provision entry with mode system/user/boot/dependency/ansible/data (or unset) that sets `format`, during create/start/restart/edit/apply/template validation.","commonSituations":"Leaving `format` behind after changing an entry from yq mode to data mode; template tools emitting format for all entries; misunderstanding that format relates to data-mode content encoding.","solutions":["Set `mode: yq` (with `path` and `expression`) if the entry edits YAML/JSON with yq","Delete the `format` field from the non-yq entry","data mode has no format option; just provide plain `content`"],"exampleFix":"# before\nprovision:\n  - mode: data\n    path: /etc/foo.yaml\n    format: yaml\n    content: a: b\n# after\nprovision:\n  - mode: data\n    path: /etc/foo.yaml\n    content: |\n      a: b","handlingStrategy":"validation","validationCode":"// Go: format requires yq mode\nfor i, p := range cfg.Provision {\n    mode := limatype.ProvisionModeSystem\n    if p.Mode != nil { mode = *p.Mode }\n    if p.Format != nil && mode != limatype.ProvisionModeYQ {\n        return fmt.Errorf(\"provision[%d]: format requires mode yq\", i)\n    }\n}","typeGuard":"func formatAllowed(p limatype.Provision) bool {\n    return p.Format == nil || (p.Mode != nil && *p.Mode == limatype.ProvisionModeYQ)\n}","tryCatchPattern":null,"preventionTips":["Only set format on yq entries editing non-default formats","Remove format when switching entries away from yq mode","Run `limactl validate` in CI on all templates"],"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"}