{"record":{"id":"176eb296e3b52563","repo":"lima-vm/lima","slug":"cannot-execute-template-q-w","errorCode":null,"errorMessage":"cannot execute template %#q: %w","messagePattern":"cannot execute template %#q: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/store/instance.go","lineNumber":139,"sourceCode":"\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 {\n\t\t\tlogrus.Warnf(\"treating lima version %#q from %#q as very latest release\", inst.LimaVersion, limaVersionFile)\n\t\t}\n\t} else if !errors.Is(err, os.ErrNotExist) {\n\t\tinst.Errors = append(inst.Errors, err)\n\t}\n\tinst.Param = y.Param\n\treturn inst, nil","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/store/instance.go#L121-L157","documentation":"The message template parsed and data was built, but tmpl.Execute failed while rendering into the message builder. This typically means the template references a field or method that does not exist on the data at execution time; the instance is marked StatusBroken.","triggerScenarios":"y.Message template references a missing/nonexistent field or calls a method that returns an error during Execute, e.g. {{ .NoSuchField }} or a nil-pointer method call in FormatData.","commonSituations":"Template written for a newer/older Lima FormatData schema (field removed in Lima 3.0 deprecations); typo in field name; using a deprecated host attribute removed from the data model.","solutions":["Remove or correct the unknown field reference in the message template in ~/.lima/<inst>/lima.yaml","Check `limactl list --list-flags` / docs for valid format fields","Update deprecated host attributes to the new top-level fields (removed in Lima 3.0)","Recreate the instance with a known-good template"],"exampleFix":"// before\nmessage: \"{{ .SSHConfigFile }} on {{ .BogusField }}\"\n// after\nmessage: \"{{ .SSHConfigFile }}\"","handlingStrategy":"validation","validationCode":"// Only reference known FormatData fields\ntmpl, err := template.New(\"f\").Parse(y.Message)\nif err == nil {\n    data, _ := store.AddGlobalFields(&limatype.Instance{})\n    if err := tmpl.Execute(io.Discard, data); err != nil {\n        // unknown field referenced; fix before Inspect\n    }\n}","typeGuard":null,"tryCatchPattern":"inst, err := store.Inspect(ctx, instDir)\nif inst.Status == limatype.StatusBroken {\n    for _, e := range inst.Errors {\n        if strings.Contains(e.Error(), \"cannot execute template\") {\n            // fix the field names in the message template\n        }\n    }\n}","preventionTips":["Stick to documented format fields (`limactl list --help` lists them)","Avoid deprecated host attributes slated for removal in Lima 3.0","Dry-run templates with tmpl.Execute against AddGlobalFields output before persisting"],"tags":["lima","go-templates","format"],"backgroundTag":"template-execute-error","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}