Conversation
The README documents both data and recipients as optional, but the
signature required them: calling with only a broadcastId crashed with a
TypeError on recipients[field], and passing {} for recipients sent an
empty recipients filter that the API rejects with a 422.
Empty or omitted data/recipients are now left out of the payload, so
triggering a broadcast with just its id sends to the broadcast's
configured recipients as documented.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jun 10, 2026
triggerBroadcast(1, { emails: [...] }) type-checks but sends the
selector as liquid data, triggering the broadcast's configured
recipients. Document the undefined placeholder pattern in the JSDoc and
README, and pin triggerBroadcast(1, undefined, recipients) with a test.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Author
|
Addressed the positional-ambiguity feedback in 17c6112:
254 tests passing, lint and build clean. |
mike-engel
previously approved these changes
Jun 11, 2026
| triggerBroadcast(broadcastId: string | number, data?: RequestData, recipients?: Recipients) { | ||
| let payload: Record<string, unknown> = {}; | ||
|
|
||
| if (data && Object.keys(data).length > 0) { |
Collaborator
There was a problem hiding this comment.
Suggested change
| if (data && Object.keys(data).length > 0) { | |
| if (data != null && Object.keys(data).length > 0) { |
| payload.data = data; | ||
| } | ||
|
|
||
| if (recipients && Object.keys(recipients).length > 0) { |
Collaborator
There was a problem hiding this comment.
Suggested change
| if (recipients && Object.keys(recipients).length > 0) { | |
| if (recipients != null && Object.keys(recipients).length > 0) { |
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
mike-engel
approved these changes
Jun 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The README documents both
dataandrecipientsas optional forapi.triggerBroadcast(), but the signature declared them as required positional arguments. Two failure modes:api.triggerBroadcast(4)—recipientsisundefined, sorecipients[field]throws a TypeErrorapi.triggerBroadcast(4, {}, {})— the emptyrecipientsobject is forwarded to the API, which rejects it with a 422 (empty recipients filter is not valid)Both params are now optional, and empty/omitted
data/recipientsare left out of the payload, so triggering a broadcast with just its id sends to the broadcast's configured recipients as documented.Test plan
{}objects for bothnpm test— 253 tests pass, coverage stays at 100%npm run lintandnpm run buildcleanFixes CDP-6131
🤖 Generated with Claude Code
Note
Low Risk
Targeted SDK fix for broadcast triggers with new tests; behavior change only affects previously broken or invalid call patterns.
Overview
APIClient.triggerBroadcastnow treatsdataandrecipientsas optional and only adds them to the POST body when they are present and non-empty. Calling with just a broadcast id sends{}, so the broadcast uses its configured recipients instead of throwing on missingrecipientsor getting a 422 from an emptyrecipientsfilter.Docs and JSDoc explain that both arguments are optional and that
recipientswithoutdatamust useundefinedfor the second positional argument. Tests cover id-only, data-only, recipients-only, and{}/{}omission.Reviewed by Cursor Bugbot for commit 6546597. Bugbot is set up for automated code reviews on this repo. Configure here.