{"record":{"id":"ca37eb4b061a8d1e","repo":"lima-vm/lima","slug":"field-provision-d-content-must-not-be-empty-wh","errorCode":null,"errorMessage":"field `provision[%d].content` must not be empty when mode is %#q","messagePattern":"field `provision\\[(.+?)\\]\\.content` must not be empty when mode is %#q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/limayaml/validate.go","lineNumber":226,"sourceCode":"\t\t\t\ti, limatype.ProvisionModeDependency))\n\t\t}\n\n\t\tif *y.OS == limatype.WINDOWS && (p.Mode == limatype.ProvisionModeAnsible || p.Mode == limatype.ProvisionModeBoot || p.Mode == limatype.ProvisionModeYQ) {\n\t\t\terrs = errors.Join(errs, fmt.Errorf(\"provision mode %#q is not supported on Windows VM\", p.Mode))\n\t\t}\n\n\t\t// This can lead to fatal Panic if p.Path is nil, better to return an error here\n\t\tswitch p.Mode {\n\t\tcase limatype.ProvisionModeData, limatype.ProvisionModeYQ:\n\t\t\tif p.Path == nil {\n\t\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `provision[%d].path` must not be empty when mode is %#q\", i, p.Mode))\n\t\t\t\treturn errs\n\t\t\t}\n\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}","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/limayaml/validate.go#L208-L244","documentation":"A provision entry with mode `data` exists to create/overwrite a file, so it must carry the file body in the `content` field. `limayaml.Validate` rejects a data-mode entry whose `content` is nil, since without content Lima would have nothing to write and the entry is meaningless.","triggerScenarios":"Any command that invokes limayaml.Validate (limactl create/start/edit/restart/apply/clone/rename/template validate/template args) on a YAML with `provision: - mode: data\n  path: /some/file` and no `content:` key (or content explicitly null).","commonSituations":"Converting a script-mode entry to mode: data and forgetting to add content; YAML multiline block scalar mis-indented so content parses as null; an anchor overriding content to empty; expecting content to be fetched from file/URL (Lima requires embedded content in this mode).","solutions":["Add a `content` key with the desired file body (use a YAML block scalar `|` for multi-line content).","If the file body should come from an external source, pre-render it into the template or use a script-mode provision with curl/heredoc instead.","If the entry was only meant to modify an existing file, consider mode: yq with an expression, but keep content if full replacement is intended."],"exampleFix":"# before\n- mode: data\n  path: /etc/motd\n# after\n- mode: data\n  path: /etc/motd\n  content: |\n    Welcome to Lima.","handlingStrategy":"validation","validationCode":"for i, p := range cfg.Provision {\n\tif p.Mode == \"data\" && p.Content == nil {\n\t\treturn fmt.Errorf(\"provision[%d]: mode data requires content\", i)\n\t}\n}","typeGuard":"func hasDataContent(p limatype.Provision) bool {\n\treturn p.Mode != limatype.ProvisionModeData || p.Content != nil\n}","tryCatchPattern":"if err := limayaml.Validate(y, false, \"config.yaml\"); err != nil {\n\tif strings.Contains(err.Error(), \"`content` must not be empty when mode is\") {\n\t\treturn fmt.Errorf(\"add content (or switch mode) for the data provision entry: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Use a YAML block scalar (content: |) so multi-line bodies parse correctly.","Check indentation after edits: a de-indented block scalar silently becomes null.","Run limactl template validate in CI for every template, catching missing content before VM creation."],"tags":["lima","limayaml","validation","provision","missing-field"],"backgroundTag":"missing-required-argument","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}