{"record":{"id":"a0a7fc56fe1c50eb","repo":"lima-vm/lima","slug":"cannot-add-global-fields-to-instance-data-w","errorCode":null,"errorMessage":"cannot add global fields to instance data: %w","messagePattern":"cannot add global fields to instance data: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/store/instance.go","lineNumber":132,"sourceCode":"\t\tinst.CPUs = 0\n\t\tinst.Disk = 0\n\t}\n\n\tprotected := filepath.Join(instDir, filenames.Protected)\n\tif _, err := os.Lstat(protected); !errors.Is(err, os.ErrNotExist) {\n\t\tinst.Protected = true\n\t}\n\n\tinspectStatus(ctx, instDir, inst, y)\n\n\ttmpl, err := template.New(\"format\").Parse(y.Message)\n\tif err != nil {\n\t\tinst.Errors = append(inst.Errors, fmt.Errorf(\"message %#q is not a valid template: %w\", y.Message, err))\n\t\tinst.Status = limatype.StatusBroken\n\t} else {\n\t\tdata, err := AddGlobalFields(inst)\n\t\tif err != nil {\n\t\t\tinst.Errors = append(inst.Errors, fmt.Errorf(\"cannot add global fields to instance data: %w\", err))\n\t\t\tinst.Status = limatype.StatusBroken\n\t\t} else {\n\t\t\tdata.Param = y.Param\n\t\t\tvar message strings.Builder\n\t\t\terr = tmpl.Execute(&message, data)\n\t\t\tif err != nil {\n\t\t\t\tinst.Errors = append(inst.Errors, fmt.Errorf(\"cannot execute template %#q: %w\", y.Message, err))\n\t\t\t\tinst.Status = limatype.StatusBroken\n\t\t\t} else {\n\t\t\t\tinst.Message = message.String()\n\t\t\t}\n\t\t}\n\t}\n\n\tlimaVersionFile := filepath.Join(instDir, filenames.LimaVersion)\n\tif version, err := os.ReadFile(limaVersionFile); err == nil {\n\t\tinst.LimaVersion = strings.TrimSpace(string(version))\n\t\tif _, err = versionutil.Parse(inst.LimaVersion); err != nil {","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/store/instance.go#L114-L150","documentation":"After the message template parses, Inspect calls AddGlobalFields(inst) to build the template data. If that helper fails, the error is recorded and the instance marked StatusBroken. AddGlobalFields computes derived/global view fields for the template data model.","triggerScenarios":"AddGlobalFields returns an error while deriving global fields (e.g. computing SSH address or other derived instance fields) during `limactl list --format` / Inspect processing.","commonSituations":"Instance struct in an inconsistent state (missing fields from a partially loaded/corrupted lima.yaml); internal bug after a Lima version change altered FormatData.","solutions":["Verify ~/.lima/<inst>/lima.yaml is well-formed and complete","Update Lima to the latest release (field-derivation bugs are fixed upstream)","Recreate the instance if its stored YAML cannot be repaired","File an issue with the Lima project if the error persists on a valid instance"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"inst, err := store.Inspect(ctx, instDir)\nif inst != nil && inst.Status == limatype.StatusBroken {\n    for _, e := range inst.Errors {\n        if strings.Contains(e.Error(), \"cannot add global fields\") {\n            // treat as internal/state error: update Lima or recreate instance\n        }\n    }\n}","preventionTips":["Keep Lima updated; AddGlobalFields failures often indicate version drift","Ensure lima.yaml is complete and uncorrupted; validate after manual edits"],"tags":["lima","go-templates","internal"],"backgroundTag":"template-data-error","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}