feat(klaviyo): add email regex validation to addProfileToList#3792
Open
AnkitSegment wants to merge 2 commits into
Open
feat(klaviyo): add email regex validation to addProfileToList#3792AnkitSegment wants to merge 2 commits into
AnkitSegment wants to merge 2 commits into
Conversation
Validate email format before sending to Klaviyo API in both single perform and batch (performBatch) paths, returning PAYLOAD_VALIDATION_FAILED in multi-status for invalid emails in batch mode. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens input validation for the Klaviyo addProfileToList action by adding a stricter email regex check (beyond the existing JSON-schema format: 'email'), and applying that validation consistently in both single-event and batched execution paths to prevent sending obviously invalid emails to Klaviyo.
Changes:
- Added a shared
validateEmailhelper and batch-path error mapping for invalid emails. - Added single
performvalidation that throwsPayloadValidationErrorwhen the email fails the regex. - Added unit tests covering single-perform invalid TLD and batch filtering behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/destination-actions/src/destinations/klaviyo/functions.ts | Adds email regex + validation helper and integrates it into batch payload validation. |
| packages/destination-actions/src/destinations/klaviyo/addProfileToList/index.ts | Applies email validation in the single perform path and wires in the helper import. |
| packages/destination-actions/src/destinations/klaviyo/addProfileToList/tests/index.test.ts | Adds tests for invalid email rejection and batch filtering. |
Comments suppressed due to low confidence (1)
packages/destination-actions/src/destinations/klaviyo/addProfileToList/index.ts:75
- This PayloadValidationError includes the raw email address in the error message. Emails are PII and may be surfaced in logs or customer-visible error surfaces; consider using a generic message (and ideally reusing the same message as the batch-path INVALID_EMAIL_ERROR) to avoid echoing user data.
if (!validateEmail(email)) {
throw new PayloadValidationError(`${email} is not a valid email address.`)
}
- Use generic error message instead of echoing email value - Fix "and" -> "or" in identifier required error message Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/) to the KlaviyoaddProfileToListactionperform(throwsPayloadValidationError) and batchperformBatch(returnsPAYLOAD_VALIDATION_FAILEDin multi-status) pathsTest plan
🤖 Generated with Claude Code