{"record":{"id":"6dccb119e36c8594","repo":"vitessio/vitess","slug":"cannot-parse-form-s","errorCode":null,"errorMessage":"cannot parse form: %s","messagePattern":"cannot parse form: (.+?)","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"go/vt/vttablet/tabletserver/livequeryz.go","lineNumber":68,"sourceCode":"\t\t\t<td>{{.Duration}}</td>\n\t\t\t<td>{{.Start}}</td>\n\t\t\t<td>{{.ConnID}}</td>\n\t\t\t<td><a href='terminate?connID={{.ConnID}}'>Terminate</a></td>\n\t\t</tr>\n\t`))\n)\n\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 {","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vttablet/tabletserver/livequeryz.go#L50-L86","documentation":"The /livequeryz handler calls r.ParseForm() and returns HTTP 500 'cannot parse form: <err>' when the request's form data is malformed and cannot be parsed. This guards the format=json query handling that follows.","triggerScenarios":"GET/POST to /livequeryz with a malformed query string or body (bad percent-encoding, invalid URL syntax) causing http.Request.ParseForm to fail.","commonSituations":"Proxies or clients double-encoding query strings; truncated requests; hand-rolled URLs with unescaped special characters like & or %.","solutions":["URL-encode query parameters correctly: /livequeryz?format=json","Fix the proxy/client generating the malformed request","Retry with a simple well-formed request to confirm the endpoint itself is healthy"],"exampleFix":"// before (unencoded)\ncurl 'http://tablet:15100/livequeryz?format=json%'\n// after\ncurl 'http://tablet:15100/livequeryz?format=json'","handlingStrategy":"validation","validationCode":"u, err := url.Parse(baseURL + \"/livequeryz\")\nif err != nil {\n    return err\n}\nu.RawQuery = \"format=json\" // let net/url encode properly","typeGuard":null,"tryCatchPattern":"resp, err := http.Get(u.String())\nif resp != nil && resp.StatusCode == http.StatusInternalServerError {\n    body, _ := io.ReadAll(resp.Body)\n    if strings.Contains(string(body), \"cannot parse form\") {\n        // fix request encoding and retry\n    }\n}","preventionTips":["Build URLs with net/url and url.Values instead of string concatenation","Avoid manual percent-encoding in query strings","Inspect proxy logs for request rewriting"],"tags":["http-api","vttablet","form-parsing"],"backgroundTag":"form-parse-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}