{"record":{"id":"49f4ee24cca5d5b8","repo":"vitessio/vitess","slug":"err-error-json-marshal-failure","errorCode":null,"errorMessage":"err.Error() (JSON marshal failure)","messagePattern":"err\\.Error\\(\\) \\(JSON marshal failure\\)","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"go/vt/vttablet/tabletserver/livequeryz.go","lineNumber":75,"sourceCode":"\nfunc livequeryzHandler(queryLists []*QueryList, w http.ResponseWriter, r *http.Request) {\n\tif err := acl.CheckAccessHTTP(r, acl.DEBUGGING); err != nil {\n\t\tacl.SendError(w, err)\n\t\treturn\n\t}\n\tvar rows []QueryDetailzRow\n\tfor _, ql := range queryLists {\n\t\trows = ql.AppendQueryzRows(rows)\n\t}\n\tif err := r.ParseForm(); err != nil {\n\t\thttp.Error(w, fmt.Sprintf(\"cannot parse form: %s\", err), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tformat := r.FormValue(\"format\")\n\tif format == \"json\" {\n\t\tjs, err := json.Marshal(rows)\n\t\tif err != nil {\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tw.Write(js)\n\t\treturn\n\t}\n\tlogz.StartHTMLTable(w)\n\tdefer logz.EndHTMLTable(w)\n\tw.Write(livequeryzHeader)\n\tfor i := range rows {\n\t\tif err := livequeryzTmpl.Execute(w, rows[i]); err != nil {\n\t\t\tlog.Error(fmt.Sprintf(\"livequeryz: couldn't execute template: %v\", err))\n\t\t}\n\t}\n}\n\nfunc livequeryzTerminateHandler(queryLists []*QueryList, w http.ResponseWriter, r *http.Request) {\n\tif err := acl.CheckAccessHTTP(r, acl.ADMIN); err != nil {","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vttablet/tabletserver/livequeryz.go#L57-L93","documentation":"When /livequeryz?format=json is requested, the handler marshals the live-query rows to JSON and returns HTTP 500 with the marshal error text if json.Marshal fails. In practice this is rare — it indicates rows contain data JSON cannot encode (e.g. unsupported types surfacing via custom marshaling).","triggerScenarios":"GET /livequeryz?format=json while json.Marshal(rows) errors on the QueryDetailzRow slice.","commonSituations":"Corrupted or unexpected values in in-flight query metadata; custom marshaler bugs after code changes; practically almost never seen with stock row types.","solutions":["Check the marshaled error text in the 500 body for the offending field","Retry without format=json to get the HTML rendering (which doesn't marshal to JSON)","Report/pin the failing row data if reproducible — this usually indicates a code bug"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"resp, err := http.Get(baseURL + \"/livequeryz?format=json\")\nif resp != nil && resp.StatusCode != http.StatusOK {\n    // fall back to the default HTML rendering\n    resp2, err := http.Get(baseURL + \"/livequeryz\")\n    _ = resp2\n    _ = err\n}","preventionTips":["Fall back to the HTML rendering when format=json fails","Report reproducible marshal failures as code bugs","Keep custom row types JSON-encodable"],"tags":["http-api","vttablet","json","internal-error"],"backgroundTag":"json-marshal-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}