Repository navigation
fix(content): display user friendly error when sending with no webhoo… - #400
Conversation
gkhngyk
left a comment
There was a problem hiding this comment.
Thanks for picking this up — the approach is exactly right: returning a discriminated result from the Server Action instead of throwing is the correct way around Next.js's production error redaction, and both single-send call sites now surface the real message. Server messages are nicely shortened too.
One change I'd like before merging, and one optional nit:
1. Bulk send still has the same bug (please fix in this PR)
bulkSendToWebhook in web/src/lib/actions/content.ts still throws on !res.ok, and handleBulkSend in web/src/app/[locale]/(dashboard)/dashboard/content/page.tsx toasts err.message. So a user who selects multiple opportunities and clicks bulk Send to Workflow with no workflow connected will still see the long generic "An error occurred in the Server Components render…" toast in production — the exact bug this PR fixes for single send.
Suggested fix, mirroring what you did for sendToWebhook:
export type BulkSendResult =
| { success: true; sent: number; failed: number }
| { success: false; error: string };
export async function bulkSendToWebhook(ids: string[]): Promise<BulkSendResult> {
// ...
if (!res.ok) {
const body = await res.json().catch(() => ({}));
return { success: false, error: body.error || `Server error: ${res.status}` };
}
const data = await res.json();
return { success: true, sent: data.sent, failed: data.failed };
}…and in handleBulkSend, toast result.error when success is false (keeping the catch as a short generic fallback).
2. Nit (optional)
In sendToWebhook, the client-side remap:
if (error.includes('No active webhook configured') || error.includes('No active webhook')) {the first condition is redundant — the second already covers it. If the intent is backward compatibility with older self-hosted servers that still return the long message, a one-line comment saying so would help; otherwise it can be dropped since the server change in this PR makes it dead code.
Happy to approve once bulk send is covered — everything else looks good and CI is green.
|
Addressed the requested changes: 1.Bulk Send now uses the same structured error handling as Single Send. |
gkhngyk
left a comment
There was a problem hiding this comment.
Both points addressed — bulk send now uses the same result pattern and the redundant condition is gone. CI is green. Thanks!
Summary
Fixes the production-only error handling for "Send to Workflow" when no workflow is connected.
Changes
sendToWebhookto return a structured success/error result instead of throwing for expected failures.Result
Users now see a concise error message (e.g. "No workflow connected") instead of the generic Next.js Server Components error in production.