{"record":{"id":"ebe53e0e288d16d6","repo":"lima-vm/lima","slug":"message-q-is-not-a-valid-template-w","errorCode":null,"errorMessage":"message %#q is not a valid template: %w","messagePattern":"message %#q is not a valid template: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/store/instance.go","lineNumber":127,"sourceCode":"\tinst.Networks = y.Networks\n\n\t// 0 out values since not configurable on WSL2\n\tif inst.VMType == limatype.WSL2 {\n\t\tinst.Memory = 0\n\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}","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/store/instance.go#L109-L145","documentation":"Inspect() renders the instance's stored lima.yaml 'message' field through a Go text/template. If template.New(\"format\").Parse fails, the message text is not a valid Go template; the instance is marked StatusBroken.","triggerScenarios":"The y.Message stored on the instance contains invalid Go template syntax: unclosed {{ }}, bad pipeline syntax, or unknown parse-time constructs introduced by editing the instance's lima.yaml directly.","commonSituations":"User hand-edited ~/.lima/<inst>/lima.yaml and broke the message template; copying a message from docs with smart quotes or mismatched braces; using unsupported template functions at parse time.","solutions":["Fix the message field in ~/.lima/<inst>/lima.yaml to be valid Go template syntax (balanced {{ }})","Validate the template locally with `go run` using text/template Parse, or via limactl template validate","Restore the original message from the template the instance was created from","Recreate the instance if the YAML is heavily corrupted"],"exampleFix":"// before (invalid template)\nmessage: \"VM is running at {{ .HostIPAddress \"\n// after\nmessage: \"VM is running at {{ .HostIPAddress }}\"","handlingStrategy":"validation","validationCode":"if _, err := template.New(\"format\").Parse(y.Message); err != nil {\n    return fmt.Errorf(\"lima.yaml message is not a valid template: %w\", err)\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(), \"not a valid template\") {\n            // repair the message field in lima.yaml before retrying\n        }\n    }\n}","preventionTips":["Validate lima.yaml with `limactl template validate` before use","Keep {{ }} balanced; paste templates as plain text to avoid smart quotes","Test custom format strings with `limactl list --format` on a throwaway instance"],"tags":["lima","go-templates","config"],"backgroundTag":"template-parse-error","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}