{"record":{"id":"7a18d92419050642","repo":"lima-vm/lima","slug":"field-uid-must-not-be-0","errorCode":null,"errorMessage":"field UID must not be 0","messagePattern":"field UID must not be 0","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cidata/template.go","lineNumber":177,"sourceCode":"\t\treturn fmt.Errorf(\"failed to get ISO label: %w\", err)\n\t}\n\n\tt.IsWindowsServer = !strings.HasPrefix(label, windowsClientISOLabelPrefix)\n\n\treturn nil\n}\n\nfunc ValidateTemplateArgs(args *TemplateArgs) error {\n\tif err := identifiers.Validate(args.Name); err != nil {\n\t\treturn err\n\t}\n\t// args.User is intentionally not validated here; the user can override with any name they want\n\t// limayaml.FillDefault will validate the default (local) username, but not an explicit setting\n\tif args.User == \"root\" {\n\t\treturn errors.New(\"field User must not be `root`\")\n\t}\n\tif args.UID == 0 {\n\t\treturn errors.New(\"field UID must not be 0\")\n\t}\n\tif args.Home == \"\" {\n\t\treturn errors.New(\"field Home must be set\")\n\t}\n\tif args.Shell == \"\" {\n\t\treturn errors.New(\"field Shell must be set\")\n\t}\n\tif len(args.SSHPubKeys) == 0 {\n\t\treturn errors.New(\"field SSHPubKeys must be set\")\n\t}\n\tfor i, m := range args.Mounts {\n\t\tf := m.MountPoint\n\t\tif !path.IsAbs(f) {\n\t\t\treturn fmt.Errorf(\"field mounts[%d] must be absolute, got %#q\", i, f)\n\t\t}\n\t}\n\treturn nil\n}","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/cidata/template.go#L159-L195","documentation":"ValidateTemplateArgs (pkg/cidata/template.go:177) requires a non-zero UID for the guest user. UID 0 is the root UID and is disallowed because Lima provisions a regular non-root user; generation fails fast with this error.","triggerScenarios":"Calling the cidata generation API with TemplateArgs.UID == 0 - e.g. constructing TemplateArgs manually in tests/tools without setting UID, or a config/builder path that fails to default the UID (limayaml.FillDefault skipped or its validation bypassed).","commonSituations":"Custom tooling building TemplateArgs directly, or a lima.yaml where explicit user settings skip FillDefault's defaulting so UID stays 0.","solutions":["Ensure the UID is populated (e.g. 1000 or from `id -u` of the host user) before calling generation","If constructing TemplateArgs manually, set args.UID to a valid non-zero value","Let limayaml.FillDefault run so UID defaults correctly instead of bypassing it"],"exampleFix":"// before\nargs := &cidata.TemplateArgs{Name: inst.Name, User: \"myuser\"}\n// after\nargs := &cidata.TemplateArgs{Name: inst.Name, User: \"myuser\", UID: 1000, Home: \"/home/myuser.linux\"}","handlingStrategy":"validation","validationCode":"if args.UID == 0 {\n    return errors.New(\"UID must be a non-zero value (e.g. 1000)\")\n}","typeGuard":null,"tryCatchPattern":"if err := cidata.ValidateTemplateArgs(args); err != nil {\n    if strings.Contains(err.Error(), \"UID must not be 0\") {\n        return fmt.Errorf(\"populate TemplateArgs.UID before generation: %w\", err)\n    }\n    return err\n}","preventionTips":["Run limayaml.FillDefault on the config so UID is defaulted (typically to the host user's UID) before building TemplateArgs","Call cidata.ValidateTemplateArgs(args) early in custom tooling","Never hardcode UID 0 when constructing TemplateArgs"],"tags":["validation","uid","cidata"],"backgroundTag":"invalid-user-config","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}