{"record":{"id":"c61e96aeb2f3fc35","repo":"lima-vm/lima","slug":"field-home-must-be-set","errorCode":null,"errorMessage":"field Home must be set","messagePattern":"field Home must be set","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cidata/template.go","lineNumber":180,"sourceCode":"\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}\n\nfunc ExecuteTemplateCloudConfig(args *TemplateArgs) ([]byte, error) {\n\tif err := ValidateTemplateArgs(args); err != nil {","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/cidata/template.go#L162-L198","documentation":"ValidateTemplateArgs (pkg/cidata/template.go:180) requires TemplateArgs.Home to be a non-empty string, since the guest user's home directory is required by the cloud-config user-data and boot templates. An empty Home aborts generation before any templates execute.","triggerScenarios":"Calling GenerateCloudConfig/GenerateISO9660/GenerateWindowsISO or ExecuteTemplateCloudConfig with TemplateArgs.Home == \"\" - typically when TemplateArgs is built manually without setting Home.","commonSituations":"Custom tooling or tests constructing TemplateArgs directly and forgetting Home; code paths that bypass limayaml.FillDefault, which normally derives Home from the user name.","solutions":["Set args.Home to the guest home path (conventionally \"/home/<user>.linux\") before generation","Run limayaml.FillDefault so Home is derived automatically","For ExecuteTemplateCloudConfig callers, populate all required fields: Name, User, UID, Home, Shell, SSHPubKeys"],"exampleFix":"// before\nargs := &cidata.TemplateArgs{Name: inst.Name, User: \"myuser\", UID: 1000}\n// after\nargs := &cidata.TemplateArgs{Name: inst.Name, User: \"myuser\", UID: 1000, Home: \"/home/myuser.linux\"}","handlingStrategy":"validation","validationCode":"if args.Home == \"\" {\n    return errors.New(\"TemplateArgs.Home must be set (e.g. /home/<user>.linux)\")\n}","typeGuard":null,"tryCatchPattern":"if err := cidata.ValidateTemplateArgs(args); err != nil {\n    if strings.Contains(err.Error(), \"field Home must be set\") {\n        return fmt.Errorf(\"set Home before cidata generation: %w\", err)\n    }\n    return err\n}","preventionTips":["Derive Home from the user name (\"/home/<user>.linux\") or let limayaml.FillDefault fill it","Call cidata.ValidateTemplateArgs(args) before any Generate*/ExecuteTemplate* call","When hand-building TemplateArgs in tests, always set Name, User, UID, Home, Shell, and SSHPubKeys together"],"tags":["validation","home-dir","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"}