vitessio/vitess · error
err.Error() (JSON marshal failure)
Error message
err.Error() (JSON marshal failure)
What it means
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).
Source
Thrown at go/vt/vttablet/tabletserver/livequeryz.go:75
func livequeryzHandler(queryLists []*QueryList, w http.ResponseWriter, r *http.Request) {
if err := acl.CheckAccessHTTP(r, acl.DEBUGGING); err != nil {
acl.SendError(w, err)
return
}
var rows []QueryDetailzRow
for _, ql := range queryLists {
rows = ql.AppendQueryzRows(rows)
}
if err := r.ParseForm(); err != nil {
http.Error(w, fmt.Sprintf("cannot parse form: %s", err), http.StatusInternalServerError)
return
}
format := r.FormValue("format")
if format == "json" {
js, err := json.Marshal(rows)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
w.Header().Set("Content-Type", "application/json")
w.Write(js)
return
}
logz.StartHTMLTable(w)
defer logz.EndHTMLTable(w)
w.Write(livequeryzHeader)
for i := range rows {
if err := livequeryzTmpl.Execute(w, rows[i]); err != nil {
log.Error(fmt.Sprintf("livequeryz: couldn't execute template: %v", err))
}
}
}
func livequeryzTerminateHandler(queryLists []*QueryList, w http.ResponseWriter, r *http.Request) {
if err := acl.CheckAccessHTTP(r, acl.ADMIN); err != nil {View on GitHub (pinned to 01a25a7d17)
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
Defensive patterns
Strategy: fallback
Try / catch
resp, err := http.Get(baseURL + "/livequeryz?format=json")
if resp != nil && resp.StatusCode != http.StatusOK {
// fall back to the default HTML rendering
resp2, err := http.Get(baseURL + "/livequeryz")
_ = resp2
_ = err
} Prevention
- Fall back to the HTML rendering when format=json fails
- Report reproducible marshal failures as code bugs
- Keep custom row types JSON-encodable
When it happens
Trigger: GET /livequeryz?format=json while json.Marshal(rows) errors on the QueryDetailzRow slice.
Common situations: Corrupted or unexpected values in in-flight query metadata; custom marshaler bugs after code changes; practically almost never seen with stock row types.
Understand the failure class
Background: json.Marshal / "failed to marshal" errors in Go: why "unsupported type" happens and how to fix it — this error's family across 22 libraries.
Related errors
- error unmarshaling query rules: %v, original data '%s' versi
- err.Error() (GetDetectionAnalysis failure)
- Method not allowed
- Missing varname or value
- err.Error() (invalid variable set value)
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/49f4ee24cca5d5b8.
Report an issue: GitHub.