Skip to content

fix(content): say a webhook redirects after a bulk send, and in the webhook test, as a single send does - #1672

Merged
gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:fix/webhook-redirect-words
Oct 28, 2026
Merged

gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:fix/webhook-redirect-words

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Follow-ups from #1590: a bulk send and the webhook test say a webhook redirects, as a single send does.

  • A webhook that redirects does so for every row. So after a bulk send the person saw "Sent 0 opportunities to workflow" and "3 failed to send", with no reason.
  • /bulk/send-webhook now counts redirects on their own: { sent, failed, redirected }. Only the Opportunities page calls it.
  • Opportunities shows the success note only when something was sent. When nothing was sent and every failure was a redirect, it uses the single send's words: "Nothing was sent: the webhook address redirects. Use the address it redirects to." The logic is in bulkSendNotes, which has its own tests.
    • Review fix (c76985f): { sent: 1, failed: 1, redirected: 1 } shows "Sent 1 opportunity" and "1 failed to send", not both success and "Nothing was sent".
  • "Sent 1 opportunities" now reads "Sent 1 opportunity".
  • The webhook test answers a 3xx with the same error a send gives (WEBHOOK_REDIRECT_ERROR). So the dialog says it's a redirect even when there's no Location header, where it used to show "HTTP 302". With a Location, it still names the address to use.

Where people see it: Content › Opportunities › bulk Send, and Webhook Settings › Test Webhook.

Related issue

Follow-ups from #1590's review.

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. cd server && npx vitest run src/routes/content-webhooks.test.js
  2. cd web && npx vitest run src/lib/content/bulk-send.test.ts

Follow-up (pre-existing, not changed here): an opportunity send still counts a 4xx or 5xx answer as sent. The docs give "non-2xx = failed" only for content_draft.sent.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

Full checks were run in one tree with this batch's ten follow-up branches merged, and again after the review fixes:

  • server format, lint and npm test: 246 files, 3,343 tests passed;
  • web format, lint (0 errors; 7 warnings already on main), typecheck and build: all pass;
  • web vitest: 447 files, 4,352 tests passed (after the review fixes).

A pre-push review was run on all ten branches.

🤖 Generated with Claude Code

cihan-gyk and others added 2 commits October 28, 2026 05:27
…ebhook test, as a single send does

Follow-ups from ansvisor#1590.

A bulk send doesn't say why. A webhook that redirects does so for every
row, so the person saw "Sent 0 opportunities to workflow" and "3 failed
to send", with no reason. /bulk/send-webhook now counts the redirects on
their own ({ sent, failed, redirected }). Opportunities shows the success
note only when something was sent, and when every failure was a redirect,
the single send's words: "Nothing was sent: the webhook address
redirects. Use the address it redirects to." (bulkSendNotes, tested on its
own; the page has no test of its own). "Sent 1 opportunities" reads
"Sent 1 opportunity" now.

The test's words for a redirect. The webhook test answers a 3xx with the
same error a send gives (WEBHOOK_REDIRECT_ERROR), so the dialog says it
for a redirect with no Location too, where it showed "HTTP 302". With a
Location it still names the address to use.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ing was

Review follow-up.

- bulkSendNotes called it a redirect whenever every failure was one, so
  { sent: 1, failed: 1, redirected: 1 } showed both "Sent 1 opportunity"
  and "Nothing was sent: the webhook address redirects". It's the redirect
  note only when nothing was sent; otherwise "1 failed to send".
- content.js: WEBHOOK_REDIRECT_ERROR sat between the imports; it's below
  them now.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, with follow-ups. CI's server job failed on content-people.test.js "puts thousands of names on one line in time near its length" (158 ms against a 150 ms limit). This PR doesn't touch that code, and the test passes here, so it's the known timing flake. Re-run the job before merging.

What I checked:

  • Merge. Two commits (d2cba2b, c76985f) on 3f6a4d4. It merges clean on main (b591947), alone and together with #1668 and #1673. Of the files it touches, only en.json changed on main since its base, and it merges on its own.
  • Server.
    • redirected counts only rows that were already counted failed because of a 3xx, so redirected <= failed always holds.
    • The webhook test adds error: WEBHOOK_REDIRECT_ERROR only for a 3xx, and the single send now uses the same constant. success and location are unchanged.
  • Web.
    • bulkSendNotes:
      • every row gets counted sent or failed, so "nothing at all" can't happen;
      • "Nothing was sent: …redirects" shows only when nothing was sent and every failure was a redirect;
      • a mix shows "Sent N" and "N failed to send".
    • The dialog already shows result.error when there's no location, so a 302 with no Location now reads as a redirect instead of "HTTP 302". With a Location it still shows testRedirect.
    • bulkSentToast now uses an ICU plural; "Sent 1 opportunity" renders.
  • Tests.
    • At the head, the content-webhooks server tests (25) and the web bulk-send and content-webhook tests (13) pass.
    • With main's content.js under the head's tests, 4 fail: the two test-redirect bodies and the two bulk counts.
  • Before the API deploy. The web reads redirected ?? 0. Until the API is deployed, a bulk send shows "N failed to send" as today. The only change is that "Sent 0 opportunities" no longer shows. The test dialog stays as it is until the API is deployed.
  • Speed. No regex and no loop over user input.

Follow-ups:

  1. An opportunity send still counts a 4xx or 5xx as sent, as the description notes. Since #1668, that also includes a 4xx or 5xx whose answer stalls past the time limit. That's worth its own issue.
  2. Nothing tests the page's toasts or the action's redirected ?? 0. bulkSendNotes carries the logic, so this is minor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants