{"record":{"id":"e370ef7421558c11","repo":"lima-vm/lima","slug":"configuration-is-nil","errorCode":null,"errorMessage":"configuration is nil","messagePattern":"configuration is nil","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/driver/hcs/hcs_driver_windows.go","lineNumber":115,"sourceCode":"\tif err := validateConfig(ctx, cfg); err != nil {\n\t\treturn nil, err\n\t}\n\n\tl.Instance = inst\n\tl.SSHLocalPort = inst.SSHLocalPort\n\n\treturn &driver.ConfiguredDriver{\n\t\tDriver: l,\n\t}, nil\n}\n\nfunc (l *LimaHcsDriver) Validate(ctx context.Context) error {\n\treturn validateConfig(ctx, l.Instance.Config)\n}\n\nfunc validateConfig(_ context.Context, cfg *limatype.LimaYAML) error {\n\tif cfg == nil {\n\t\treturn errors.New(\"configuration is nil\")\n\t}\n\t// TODO: revise this list for HCS\n\tif cfg.VMType != nil {\n\t\tif unknown := reflectutil.UnknownNonEmptyFields(cfg, knownYamlProperties...); len(unknown) > 0 {\n\t\t\tlogrus.Warnf(\"Ignoring: vmType %s: %+v\", *cfg.VMType, unknown)\n\t\t}\n\t}\n\n\tif cfg.OS != nil && *cfg.OS == limatype.WINDOWS {\n\t\treturn errors.New(\"currently Windows guest OS is only supported on QEMU\")\n\t}\n\n\tif !limatype.IsNativeArch(*cfg.Arch) {\n\t\treturn fmt.Errorf(\"unsupported arch: %#q\", *cfg.Arch)\n\t}\n\n\tif cfg.TPM != nil && *cfg.TPM {\n\t\treturn errors.New(\"field `tpm` is not supported on HCS driver\")","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/driver/hcs/hcs_driver_windows.go#L97-L133","documentation":"validateConfig for the HCS driver requires a non-nil instance config; if cfg (*limatype.LimaYAML) is nil it returns 'configuration is nil'. This guards Validate/Configure against dereferencing a config that was never loaded, so it signals a lifecycle/initialization bug rather than a user YAML mistake.","triggerScenarios":"validateConfig invoked from Validate, Configure, or an anonymous callback with l.Instance.Config unset — instance struct constructed without loading lima.yaml, or Configure called before the config was populated by the instance loader.","commonSituations":"Programmatic use of the driver package where LimaYAML was never loaded via limayaml.Load; instance directory missing lima.yaml so the loader left Config nil; calling Validate out of the normal limactl create flow.","solutions":["Load the config before validating: cfg, err := limayaml.Load(yamlPath, filePath) and assign it to Instance.Config","Ensure the instance directory contains a valid lima.yaml (recreate the instance if missing)","Fix the calling code so Validate/Configure run only after config population"],"exampleFix":"// before\ndrv := &hcs.LimaHcsDriver{Instance: &limatype.Instance{Name: \"x\"}} // Config nil\n_ = drv.Validate(ctx) // configuration is nil\n// after\ncfg, err := limayaml.Load(yamlBytes, \"lima.yaml\")\nif err != nil { return err }\ndrv.Instance.Config = cfg\n_ = drv.Validate(ctx)","handlingStrategy":"validation","validationCode":"func ensureConfig(inst *limatype.Instance) error {\n\tif inst == nil || inst.Config == nil {\n\t\treturn errors.New(\"instance config not loaded; call limayaml.Load and assign Instance.Config first\")\n\t}\n\treturn nil\n}","typeGuard":"func hasConfig(inst *limatype.Instance) bool {\n\treturn inst != nil && inst.Config != nil\n}","tryCatchPattern":"if err := drv.Validate(ctx); err != nil {\n\tif err.Error() == \"configuration is nil\" {\n\t\t// lifecycle bug: config was never loaded; load it and retry validation\n\t\treturn loadAndValidate(ctx, inst)\n\t}\n\treturn err\n}","preventionTips":["Always load lima.yaml via limayaml.Load before constructing/validating a driver","Call Validate/Configure only through the normal limactl create flow","Check that the instance directory exists and contains lima.yaml before driver setup","In embedded use, assert inst.Config != nil at construction time"],"tags":["hcs","validation","nil-config","windows"],"backgroundTag":"nil-config-validation","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}