{"record":{"id":"64204bbfcab4948b","repo":"lima-vm/lima","slug":"field-memory-has-an-invalid-value-w","errorCode":null,"errorMessage":"field `memory` has an invalid value: %w","messagePattern":"field `memory` has an invalid value: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/limayaml/validate.go","lineNumber":111,"sourceCode":"\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, \"~\") {\n\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `mounts[%d].location` must be an absolute path, got %#q\",\n\t\t\t\ti, f.Location))\n\t\t}\n\t\t// f.Location has already been expanded in FillDefaults(), but that function cannot return errors.","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/limayaml/validate.go#L93-L129","documentation":"The `memory` field is parsed with docker/go-units RAMInBytes, which accepts values like \"4GiB\", \"4GB\", \"4096MB\", or bare byte counts. Any unparseable string (\"4 Gigs\", \"4Gi\", \"4gb \", negative or garbage) produces a parse error wrapped by this message.","triggerScenarios":"`memory` set to a string units.RAMInBytes cannot parse, e.g. `memory: 4Gi`, `memory: 4 G`, or a non-numeric string; Validate() invoked on a YAML whose memory key is malformed.","commonSituations":"Typos in size suffixes; adding spaces or locale-formatted numbers; using \"k\"/\"ki\" inconsistently; quoting mistakes in YAML producing unexpected strings.","solutions":["Use an accepted format like `memory: 4GiB` (or \"4096MB\")","Drop the space between number and unit (`4 GiB` -> `4GiB`)","Verify the YAML quoting so the value is a plain scalar string"],"exampleFix":"// before\nmemory: 4 GiB\n// after\nmemory: 4GiB","handlingStrategy":"validation","validationCode":"import \"github.com/docker/go-units\"\n\nfunc validMemory(mem string) bool {\n\t_, err := units.RAMInBytes(mem)\n\treturn err == nil\n}","typeGuard":null,"tryCatchPattern":"if err := limayaml.Validate(y, false); err != nil {\n\tif strings.Contains(err.Error(), \"field `memory` has an invalid value\") {\n\t\treturn fmt.Errorf(\"bad memory format (use e.g. 4GiB): %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Use formats like 4GiB, 4096MB, or plain bytes","Pre-validate with units.RAMInBytes before writing the template","Avoid spaces and unsupported suffixes; don't abbreviate GiB as Gi"],"tags":["lima","memory","units","parsing"],"backgroundTag":"invalid-size-format","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}