juanfont/headscale · error

bad form data

Error message

bad form data

What it means

Error "bad form data" thrown in juanfont/headscale.

Source

Thrown at hscontrol/debug.go:191

	debug.Handle("batcher", "Batcher connected nodes", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		writeDebug(w, r, func() any { return h.debugBatcherJSON() }, h.debugBatcher)
	}))

	// Ping endpoint: sends a [tailcfg.PingRequest] to a node and waits for it to respond.
	// Supports POST (form submit) and GET with ?node= (clickable quick-ping links).
	debug.Handle("ping", "Ping a node to check connectivity", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		var (
			query  string
			result *templates.PingResult
		)

		switch r.Method {
		case http.MethodPost:
			r.Body = http.MaxBytesReader(w, r.Body, 4096) //nolint:mnd

			err := r.ParseForm()
			if err != nil {
				http.Error(w, "bad form data", http.StatusBadRequest)
				return
			}

			query = r.FormValue("node")
			result = h.doPing(r.Context(), query)
		case http.MethodGet:
			// Support ?node= for auto-ping links from other debug pages.
			if q := r.URL.Query().Get("node"); q != "" {
				query = q
				result = h.doPing(r.Context(), query)
			}
		}

		nodes := h.connectedNodesList()

		w.Header().Set("Content-Type", "text/html; charset=utf-8")
		w.WriteHeader(http.StatusOK)
		_, _ = w.Write([]byte(templates.PingPage(query, result, nodes).Render())) //nolint:gosec // G705: templ component auto-escapes

View on GitHub (pinned to 565fd254d0)

Solutions

  1. Inspect the wrapped error for the underlying cause and correct the failing condition (bad form data); retry the operation after fixing the input, configuration, or environment.

Example fix

Inspect the wrapped error for the underlying cause and correct the failing condition (bad form data); retry the operation after fixing the input, configuration, or environment.

When it happens

Trigger: Thrown at hscontrol/debug.go:191 when the library encounters an invalid state.

Common situations: The submitted form data to the debug endpoint could not be parsed. Submit a valid application/x-www-form-urlencoded body.


AI-assisted analysis of juanfont/headscale@565fd254d0 (2026-08-15). Data as JSON: /api/errors/e747ba87d4f51008. Report an issue: GitHub.