{"record":{"id":"7a261eb2c98246b9","repo":"lima-vm/lima","slug":"field-cpus-must-be-set","errorCode":null,"errorMessage":"field `cpus` must be set","messagePattern":"field `cpus` must be set","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/limayaml/validate.go","lineNumber":107,"sourceCode":"\t\t\t\terrs = errors.Join(errs, err)\n\t\t\t}\n\t\t\tif f.Kernel.Arch != f.Arch {\n\t\t\t\terrs = errors.Join(errs, fmt.Errorf(\"images[%d].kernel has unexpected architecture %#q, must be %#q\", i, f.Kernel.Arch, f.Arch))\n\t\t\t}\n\t\t}\n\t\tif f.Initrd != nil {\n\t\t\terr := validateFileObject(*f.Initrd, fmt.Sprintf(\"images[%d].initrd\", i))\n\t\t\tif err != nil {\n\t\t\t\terrs = errors.Join(errs, err)\n\t\t\t}\n\t\t\tif f.Initrd.Arch != f.Arch {\n\t\t\t\terrs = errors.Join(errs, fmt.Errorf(\"images[%d].initrd has unexpected architecture %#q, must be %#q\", i, f.Initrd.Arch, f.Arch))\n\t\t\t}\n\t\t}\n\t}\n\n\tif *y.CPUs == 0 {\n\t\terrs = errors.Join(errs, errors.New(\"field `cpus` must be set\"))\n\t}\n\n\tif _, err := units.RAMInBytes(*y.Memory); err != nil {\n\t\terrs = errors.Join(errs, fmt.Errorf(\"field `memory` has an invalid value: %w\", err))\n\t}\n\n\tif _, err := units.RAMInBytes(*y.Disk); err != nil {\n\t\terrs = errors.Join(errs, fmt.Errorf(\"field `disk` has an invalid value: %w\", err))\n\t}\n\n\tfor i, disk := range y.AdditionalDisks {\n\t\tif err := identifiers.Validate(disk.Name); err != nil {\n\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `additionalDisks[%d].name is invalid`: %w\", i, err))\n\t\t}\n\t}\n\n\tfor i, f := range y.Mounts {\n\t\tif !filepath.IsAbs(f.Location) && !strings.HasPrefix(f.Location, \"~\") {","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/limayaml/validate.go#L89-L125","documentation":"The `cpus` field is empty after defaults are applied, so the number of vCPUs for the guest is unknown.","triggerScenarios":"`cpus: 0` in the template, or Validate() called on a LimaYAML that skipped FillDefault() so *y.CPUs is still 0.","commonSituations":"Explicitly setting cpus: 0 to mean \"unlimited\"; constructing a LimaYAML struct programmatically and calling Validate without defaults; YAML merge losing the cpus key.","solutions":["Set `cpus` to a positive integer (e.g. 4)","Remove an explicit `cpus: 0` line and run `limactl create` so defaults apply","When calling Validate() in code, call FillDefault() first"],"exampleFix":"// before\ncpus: 0\n// after\ncpus: 4","handlingStrategy":"validation","validationCode":"func cpusSet(y *limatype.LimaYAML) bool {\n\treturn y.CPUs != nil && *y.CPUs > 0\n}","typeGuard":null,"tryCatchPattern":"if err := limayaml.Validate(y, false); err != nil {\n\tif strings.Contains(err.Error(), \"field `cpus` must be set\") {\n\t\treturn fmt.Errorf(\"cpus must be a positive integer: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Never set cpus: 0; use a positive value or omit the key","When building LimaYAML in Go, call FillDefault() before Validate()","Check that YAML merges/base templates preserve the cpus key"],"tags":["lima","cpus","config-validation"],"backgroundTag":"missing-required-argument","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}