vitessio/vitess · warning

err.Error()

Error message

err.Error()

What it means

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.

Source

Thrown at go/streamlog/streamlog.go:208

	delete(logger.subscribed, ch)
}

// Name returns the name of StreamLogger.
func (logger *StreamLogger[T]) Name() string {
	return logger.name
}

// ServeLogs registers the URL on which messages will be broadcast.
// It is safe to register multiple URLs for the same StreamLogger.
func (logger *StreamLogger[T]) ServeLogs(url string, logf LogFormatter) {
	servenv.HTTPHandleFunc(url, func(w http.ResponseWriter, r *http.Request) {
		if err := acl.CheckAccessHTTP(r, acl.DEBUGGING); err != nil {
			acl.SendError(w, err)
			return
		}
		if err := r.ParseForm(); err != nil {
			http.Error(w, err.Error(), http.StatusBadRequest)
		}
		ch := logger.Subscribe("ServeLogs")
		defer logger.Unsubscribe(ch)

		// Notify client that we're set up. Helpful to distinguish low-traffic streams from connection issues.
		w.WriteHeader(http.StatusOK)
		w.(http.Flusher).Flush()

		for message := range ch {
			if err := logf(w, r.Form, message); err != nil {
				return
			}
			w.(http.Flusher).Flush()
		}
	})
	log.Info(fmt.Sprintf("Streaming logs from %s at %v.", logger.Name(), url))
}

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Fix the requesting URL: percent-encode special characters in the query string (e.g. %25 for a literal %).
  2. Retry with a plain path and no query parameters to confirm the endpoint itself works.
  3. If a tool/proxy generates the URL, URL-encode the values it interpolates (e.g. url.QueryEscape in Go).

Example fix

// before
curl 'http://localhost:15001/logz?pattern=%zz'
// after
curl 'http://localhost:15001/logz?pattern=%25zz'
Defensive patterns

Strategy: validation

Validate before calling

u, err := url.Parse(rawURL)
if err != nil {
	return err
}
// force parse of query to catch malformed escapes before sending
if _, err := url.ParseQuery(u.RawQuery); err != nil {
	return fmt.Errorf("malformed query: %w", err)
}

Prevention

When it happens

Trigger: 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.

Common situations: Hand-built monitoring URLs with unencoded special characters; curl commands with stray '%' in query params; proxies mangling query strings; automated scrapers generating malformed URLs.

Related errors


AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01). Data as JSON: /api/errors/36691c8c5a143d61. Report an issue: GitHub.