{"record":{"id":"99866f573214b7b1","repo":"lima-vm/lima","slug":"field-os-must-be-one-of-q-got-q","errorCode":null,"errorMessage":"field `os` must be one of %#q; got %#q","messagePattern":"field `os` must be one of %#q; got %#q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/limayaml/validate.go","lineNumber":61,"sourceCode":"\t\t}\n\t\t// Unparsable version.Version (like commit hashes or \"<unknown>\") is treated as \"latest/greatest\"\n\t\t// and will pass all version comparisons, allowing development builds to work.\n\t\tif !versionutil.GreaterEqual(version.Version, *y.MinimumLimaVersion) {\n\t\t\terrs = errors.Join(errs, fmt.Errorf(\"template requires Lima version %#q; this is only %#q\", *y.MinimumLimaVersion, version.Version))\n\t\t}\n\t}\n\n\tswitch *y.OS {\n\tcase limatype.LINUX, limatype.DARWIN, limatype.FREEBSD:\n\tcase limatype.WINDOWS:\n\t\tif *y.VMType != limatype.QEMU {\n\t\t\terrs = errors.Join(errs, fmt.Errorf(\"currently Windows guest is only supported on %#q; got %#q\", limatype.QEMU, *y.VMType))\n\t\t}\n\t\tif !slices.Contains([]limatype.Arch{limatype.X8664, limatype.AARCH64}, *y.Arch) {\n\t\t\terrs = errors.Join(errs, fmt.Errorf(\"currently Windows guest is only supported on [%#q, %#q]; got %#q\", limatype.X8664, limatype.AARCH64, *y.Arch))\n\t\t}\n\tdefault:\n\t\terrs = errors.Join(errs, fmt.Errorf(\"field `os` must be one of %#q; got %#q\", limatype.OSTypes, *y.OS))\n\t}\n\tif !slices.Contains(limatype.ArchTypes, *y.Arch) {\n\t\terrs = errors.Join(errs, fmt.Errorf(\"field `arch` must be one of %v; got %#q\", limatype.ArchTypes, *y.Arch))\n\t}\n\n\tif y.User.Shell != nil {\n\t\tshell := *y.User.Shell\n\t\tif *y.OS == limatype.WINDOWS {\n\t\t\tif !IsSupportedWindowsShell(shell) {\n\t\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `user.shell` must be one of %v for Windows guest, got %#q\", SupportedWindowsShells, shell))\n\t\t\t}\n\t\t} else if !path.IsAbs(shell) {\n\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `user.shell` must be an absolute path, got %#q\", shell))\n\t\t}\n\t}\n\n\tif len(y.Images) == 0 {\n\t\terrs = errors.Join(errs, errors.New(\"field `images` must be set\"))","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/limayaml/validate.go#L43-L79","documentation":"The `os` field must be one of the supported guest OS types (linux, darwin, freebsd, windows). Any other value (typo, unsupported OS, empty string surviving defaults) fails validation. Thrown by Validate() in pkg/limayaml/validate.go during all template-consuming actions.","triggerScenarios":"`os` in the lima.yaml is set to a value not in limatype.OSTypes, e.g. `os: windows11`, `os: win`, or a misspelling like `os: linuz`.","commonSituations":"Typos when hand-editing templates; copying `os` values from other tools; forgetting that guest OS differs from host OS.","solutions":["Set `os` to one of: linux, darwin, freebsd, windows","Remove the `os` line to accept the default (linux)","Run `limactl template validate <file>` to check before create"],"exampleFix":"// before\nos: linuz\n// after\nos: linux","handlingStrategy":"validation","validationCode":"func validOS(os string) bool {\n\treturn slices.Contains(limatype.OSTypes, limatype.OS(os))\n}","typeGuard":"func isSupportedOS(os string) bool {\n\tfor _, t := range limatype.OSTypes {\n\t\tif string(t) == os { return true }\n\t}\n\treturn false\n}","tryCatchPattern":"if err := limayaml.Validate(y, false); err != nil {\n\tif strings.Contains(err.Error(), \"field `os` must be one of\") {\n\t\treturn fmt.Errorf(\"fix the os field: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Copy os values from official templates rather than typing them","Validate templates in CI with limactl template validate","Remember guest OS defaults to linux; only set it intentionally"],"tags":["lima","os-field","config-validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}