plandex-ai/plandex · error · http

Error marshalling response

Error message

Error marshalling response

What it means

After a successful update, the handler marshals shared.UpdateSettingsResponse{Msg: commitMsg} to JSON. Failure is extremely unlikely for this fixed struct but would yield HTTP 500 'Error marshalling response'.

Source

Thrown at app/server/handlers/settings.go:215

		}

		return nil
	})

	if err != nil {
		log.Println("Error updating settings: ", err)
		http.Error(w, "Error updating settings", http.StatusInternalServerError)
		return
	}

	res := shared.UpdateSettingsResponse{
		Msg: commitMsg,
	}
	bytes, err := json.Marshal(res)

	if err != nil {
		log.Println("Error marshalling response: ", err)
		http.Error(w, "Error marshalling response", http.StatusInternalServerError)
		return
	}

	w.Write(bytes)

	log.Println("UpdateSettingsHandler processed successfully")

}

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

	auth := Authenticate(w, r, true)
	if auth == nil {
		return
	}

	settings, err := db.GetOrgDefaultSettings(auth.OrgId)

View on GitHub (pinned to e2d772072e)

Solutions

  1. Keep UpdateSettingsResponse JSON-safe (strings/basic types only)
  2. If a custom MarshalJSON exists on the response, fix its error path
  3. Pin the shared package version to match the server build
Defensive patterns

Strategy: try-catch

Try / catch

resp, err := client.UpdateSettings(ctx, req)
if err != nil {
    // 500 'Error marshalling response' is a server bug; surface it and stop
    return fmt.Errorf("settings updated but response malformed: %w", err)
}

Prevention

When it happens

Trigger: json.Marshal(res) fails, practically only if UpdateSettingsResponse gains non-serializable fields or commitMsg carries values causing custom MarshalJSON to error.

Common situations: Code changes add a func/chan field or custom marshaler to UpdateSettingsResponse; build with mismatched shared package versions.

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/40f4bee999f31ba7. Report an issue: GitHub.