{"record":{"id":"36691c8c5a143d61","repo":"vitessio/vitess","slug":"err-error","errorCode":null,"errorMessage":"err.Error()","messagePattern":"err\\.Error\\(\\)","errorType":"http","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"go/streamlog/streamlog.go","lineNumber":208,"sourceCode":"\n\tdelete(logger.subscribed, ch)\n}\n\n// Name returns the name of StreamLogger.\nfunc (logger *StreamLogger[T]) Name() string {\n\treturn logger.name\n}\n\n// ServeLogs registers the URL on which messages will be broadcast.\n// It is safe to register multiple URLs for the same StreamLogger.\nfunc (logger *StreamLogger[T]) ServeLogs(url string, logf LogFormatter) {\n\tservenv.HTTPHandleFunc(url, func(w http.ResponseWriter, r *http.Request) {\n\t\tif err := acl.CheckAccessHTTP(r, acl.DEBUGGING); err != nil {\n\t\t\tacl.SendError(w, err)\n\t\t\treturn\n\t\t}\n\t\tif err := r.ParseForm(); err != nil {\n\t\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\t}\n\t\tch := logger.Subscribe(\"ServeLogs\")\n\t\tdefer logger.Unsubscribe(ch)\n\n\t\t// Notify client that we're set up. Helpful to distinguish low-traffic streams from connection issues.\n\t\tw.WriteHeader(http.StatusOK)\n\t\tw.(http.Flusher).Flush()\n\n\t\tfor message := range ch {\n\t\t\tif err := logf(w, r.Form, message); err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tw.(http.Flusher).Flush()\n\t\t}\n\t})\n\tlog.Info(fmt.Sprintf(\"Streaming logs from %s at %v.\", logger.Name(), url))\n}\n","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/streamlog/streamlog.go#L190-L226","documentation":"The /streamlog (e.g. /logz-style) HTTP handler calls r.ParseForm() before streaming logs; if the incoming request has malformed form data (bad URL encoding in query string or body), it responds 400 Bad Request with err.Error(). This surfaces raw net/url parse errors to the HTTP client.","triggerScenarios":"GET/POST to a streamlog endpoint (e.g. /logz, /syslogz) whose query string or body contains invalid percent-encoding (e.g. %zz) or other malformed form data, causing http.Request.ParseForm to fail.","commonSituations":"Hand-built monitoring URLs with unencoded special characters; curl commands with stray '%' in query params; proxies mangling query strings; automated scrapers generating malformed URLs.","solutions":["Fix the requesting URL: percent-encode special characters in the query string (e.g. %25 for a literal %).","Retry with a plain path and no query parameters to confirm the endpoint itself works.","If a tool/proxy generates the URL, URL-encode the values it interpolates (e.g. url.QueryEscape in Go)."],"exampleFix":"// before\ncurl 'http://localhost:15001/logz?pattern=%zz'\n// after\ncurl 'http://localhost:15001/logz?pattern=%25zz'","handlingStrategy":"validation","validationCode":"u, err := url.Parse(rawURL)\nif err != nil {\n\treturn err\n}\n// force parse of query to catch malformed escapes before sending\nif _, err := url.ParseQuery(u.RawQuery); err != nil {\n\treturn fmt.Errorf(\"malformed query: %w\", err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always URL-encode query parameter values (url.QueryEscape / encodeURIComponent).","Test monitoring URLs with curl before adding them to dashboards.","Keep logz query patterns simple; avoid raw % and unencoded spaces in query strings."],"tags":["http","url-parsing","bad-request"],"backgroundTag":"malformed-url-query","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}