plandex-ai/plandex · warning · http

Error marshalling response:

Error message

Error marshalling response: 

What it means

This error is returned when json.Marshal fails to serialize the CreateEmailVerificationResponse before writing it to the ResponseWriter. The handler responds with HTTP 500 prefixed 'Error marshalling response: '. This is nearly impossible with the plain response struct, so it almost always indicates a custom MarshalJSON implementation or an unexpected value in the struct.

Source

Thrown at app/server/handlers/sessions.go:129

			http.Error(w, "Error sending verification email: "+err.Error(), http.StatusInternalServerError)
			return
		}

		res = shared.CreateEmailVerificationResponse{
			HasAccount: hasAccount,
		}
	} else {
		res = shared.CreateEmailVerificationResponse{
			HasAccount:  hasAccount,
			IsLocalMode: true,
		}
	}

	bytes, err := json.Marshal(res)

	if err != nil {
		log.Printf("Error marshalling response: %v\n", err)
		http.Error(w, "Error marshalling response: "+err.Error(), http.StatusInternalServerError)
		return
	}

	log.Println("Successfully created email verification")

	w.Write(bytes)
}

func CheckEmailPinHandler(w http.ResponseWriter, r *http.Request) {
	log.Println("Received request for VerifyEmailPinHandler")

	// read the request body
	body, err := io.ReadAll(r.Body)
	if err != nil {
		log.Printf("Error reading request body: %v\n", err)
		http.Error(w, "Error reading request body: "+err.Error(), http.StatusInternalServerError)
		return
	}

View on GitHub (pinned to e2d772072e)

Solutions

  1. Check the log for the wrapped marshal error to see which field failed
  2. Pin/restore a known-good version of the plandex-shared dependency
  3. Remove or fix any custom MarshalJSON on CreateEmailVerificationResponse fields
  4. Ensure the response struct contains only marshalable types

Example fix

// before
bytes, err := json.Marshal(res)
if err != nil {
	http.Error(w, "Error marshalling response: "+err.Error(), http.StatusInternalServerError)
	return
}
// after: guard with a safe fallback so clients never get a 500 for a plain struct
bytes, err := json.Marshal(res)
if err != nil {
	log.Printf("Error marshalling response: %v\n", err)
	bytes, _ = json.Marshal(shared.CreateEmailVerificationResponse{HasAccount: false})
}
Defensive patterns

Strategy: try-catch

Try / catch

// server-side safe marshal
bytes, err := json.Marshal(res)
if err != nil {
	log.Printf("marshal failed: %v", err)
	bytes, _ = json.Marshal(shared.CreateEmailVerificationResponse{})
}
w.Write(bytes)

Prevention

When it happens

Trigger: json.Marshal(res) failing on shared.CreateEmailVerificationResponse — practically only if a field has a custom marshaler that returns an error, or the shared module version in use has a field that cannot be marshaled (e.g. a bad custom type).

Common situations: Plandex-shared module upgraded/patched with a custom MarshalJSON that errors; build using a mismatched or vendored plandex-shared version; replacing the response struct with one containing unmarshalable types (channels, funcs, cyclic pointers).

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


AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05). Data as JSON: /api/errors/341e4c6f2307b9c1. Report an issue: GitHub.