{"record":{"id":"7ededa6cfda6b252","repo":"lima-vm/lima","slug":"field-provision-d-path-must-not-be-empty-when","errorCode":null,"errorMessage":"field `provision[%d].path` must not be empty when mode is %#q","messagePattern":"field `provision\\[(.+?)\\]\\.path` must not be empty when mode is %#q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/limayaml/validate.go","lineNumber":219,"sourceCode":"\t\tcase limatype.ProvisionModeSystem, limatype.ProvisionModeUser, limatype.ProvisionModeBoot, limatype.ProvisionModeData, limatype.ProvisionModeDependency, limatype.ProvisionModeAnsible, limatype.ProvisionModeYQ:\n\t\tdefault:\n\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `provision[%d].mode` must one of %#q, %#q, %#q, %#q, %#q, %#q, or %#q\",\n\t\t\t\ti, limatype.ProvisionModeSystem, limatype.ProvisionModeUser, limatype.ProvisionModeBoot, limatype.ProvisionModeData, limatype.ProvisionModeDependency, limatype.ProvisionModeAnsible, limatype.ProvisionModeYQ))\n\t\t}\n\t\tif p.Mode != limatype.ProvisionModeDependency && p.SkipDefaultDependencyResolution != nil {\n\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `provision[%d].mode` cannot set skipDefaultDependencyResolution, only valid on scripts of type %#q\",\n\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))","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/limayaml/validate.go#L201-L237","documentation":"In `limayaml.Validate`, provision entries with mode `data` or `yq` must declare the guest file they operate on via the `path` field. A nil `path` is rejected explicitly (with an early return) because later validation and the CIDATA generation would dereference it and panic, and there is no meaningful default target file for these modes.","triggerScenarios":"Any Validate-calling command (create/start/edit/restart/apply/clone/rename/template validate/template args) on a YAML containing `provision: - mode: data` (or `mode: yq`) without a `path:` key.","commonSituations":"Writing a data-mode file entry and omitting path because script-mode entries don't need one; a partial merge/anchor that drops the path key; hand-editing a template and deleting the path line while keeping content or expression.","solutions":["Add a `path` key with the absolute guest file path to the data/yq provision entry.","If the entry was meant to run a script, switch the mode to \"user\"/\"system\" and use `script` instead of path/content.","Re-validate with limactl template validate before starting the instance."],"exampleFix":"# before\nprovision:\n  - mode: data\n    content: \"hello\"\n# after\nprovision:\n  - mode: data\n    path: /etc/hello.conf\n    content: \"hello\"","handlingStrategy":"validation","validationCode":"for i, p := range cfg.Provision {\n\tif (p.Mode == \"data\" || p.Mode == \"yq\") && p.Path == nil {\n\t\treturn fmt.Errorf(\"provision[%d]: mode %q requires a path\", i, p.Mode)\n\t}\n}","typeGuard":"func provisionNeedsPath(p limatype.Provision) bool {\n\treturn p.Mode == limatype.ProvisionModeData || p.Mode == limatype.ProvisionModeYQ\n}","tryCatchPattern":"if err := limayaml.Validate(y, false, \"config.yaml\"); err != nil {\n\tif strings.Contains(err.Error(), \"`provision[\") && strings.Contains(err.Error(), \"must not be empty when mode is\") {\n\t\treturn fmt.Errorf(\"fix the data/yq provision entry (add path): %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Always pair mode: data / mode: yq entries with a path key in your templates.","Validate templates with limactl template validate before limactl create.","When switching an entry between script and file modes, re-check the required fields (script vs path+content/expression)."],"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"}