Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: email validation for braze #2929

Merged
merged 2 commits into from
Dec 18, 2023
Merged

fix: email validation for braze #2929

merged 2 commits into from
Dec 18, 2023

Conversation

aashishmalik
Copy link
Contributor

@aashishmalik aashishmalik commented Dec 18, 2023

What are the changes introduced in this PR?

email validation for braze if integer or obj

Write a brief explainer on your code changes.

Please explain the objectives of your changes below

Put down any required details on the broader aspect of your changes. If there are any dependent changes, mandatorily mention them here

Type of change

If the pull request is a bug-fix, enhancement or a refactor, please fill in the details on the changes made.

  • Existing capabilities/behavior

  • New capabilities/behavior

If the pull request is a new feature,

Any technical or performance related pointers to consider with the change?

N/A

Any new dependencies introduced with this change?

N/A

Any new generic utility introduced or modified. Please explain the changes.

N/A

If the PR has changes in more than 10 files, please mention why the changes were not split into multiple PRs.

N/A

If multiple linear tasks are associated with the PR changes, please elaborate on the reason:

N/A


Developer checklist

  • No breaking changes are being introduced.

  • Are all related docs linked with the PR?

  • Are all changes manually tested?

  • Does this change require any documentation changes?

  • Are relevant unit and component test-cases added?

Reviewer checklist

  • Is the type of change in the PR title appropriate as per the changes?

  • Verified that there are no credentials or confidential data exposed with the changes.

@aashishmalik aashishmalik requested review from a team as code owners December 18, 2023 04:43
@aashishmalik aashishmalik requested review from krishna2020 and ItsSudip and removed request for a team December 18, 2023 04:43
Copy link
Contributor

coderabbitai bot commented Dec 18, 2023

Important

Auto Review Skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository.

To trigger a single review, invoke the @coderabbitai review command.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on X ?


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • You can reply to a review comment made by CodeRabbit.
  • You can tag CodeRabbit on specific lines of code or files in the PR by tagging @coderabbitai in a comment.
  • You can tag @coderabbitai in a PR comment and ask one-off questions about the PR and the codebase. Use quoted replies to pass the context for follow-up questions.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

@aashishmalik aashishmalik requested review from koladilip and removed request for krishna2020 December 18, 2023 04:43
Copy link

codecov bot commented Dec 18, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (44755f3) 87.27% compared to head (cc47c15) 87.27%.

Additional details and impacted files
@@              Coverage Diff               @@
##           hotfix/Dec.18    #2929   +/-   ##
==============================================
  Coverage          87.27%   87.27%           
==============================================
  Files                790      790           
  Lines              29211    29217    +6     
  Branches            6831     6834    +3     
==============================================
+ Hits               25494    25500    +6     
  Misses              3373     3373           
  Partials             344      344           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -155,8 +155,8 @@ function getUserAttributesObject(message, mappingJson, destination) {
let value = get(traits, mappingJson[destKey]);
if (value || (value === null && reservedKeys.includes(destKey))) {
// if email is not string remove it from attributes
if (destKey === 'email' && typeof value !== 'string') {
throw new InstrumentationError('Invalid email, email must be a valid string');
if (destKey === 'email' && Number.isInteger(value)) {
Copy link
Contributor

@koladilip koladilip Dec 18, 2023

Choose a reason for hiding this comment

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

switch (destKey) {
        case 'gender':
          value = formatGender(value);
          break;
        case 'email':
          if (typeof value === 'string') {
            value = value.toLowerCase();
          } else if (value !== null){
            throw new InstrumentationError('Invalid email, email must be a valid string');
          }
          break;
        default:
          break;
      }

What about this?

Copy link
Contributor Author

@aashishmalik aashishmalik Dec 18, 2023

Choose a reason for hiding this comment

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

if v is null ..then our first check v!== 'string' will be true and gives NPE...we will never go to else if condition

Copy link
Contributor

Choose a reason for hiding this comment

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

corrected now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

Copy link

src/v0/destinations/braze/transform.js Show resolved Hide resolved
"_update_existing_only": false,
"city": "Disney",
"country": "USA",
"email": null,
Copy link
Member

Choose a reason for hiding this comment

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

Email is still coming as null

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we want to allow email as this is reserved keys and should pass as it is.

Copy link
Contributor Author

@aashishmalik aashishmalik Dec 18, 2023

Choose a reason for hiding this comment

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

earlier code if (value || (value === null && reservedKeys.includes(destKey))) { ... is checking against reservedKeys ..even if it is null

@aashishmalik aashishmalik merged commit 28207d0 into hotfix/Dec.18 Dec 18, 2023
15 checks passed
@aashishmalik aashishmalik deleted the fix/braze-email branch December 18, 2023 06:46
koladilip pushed a commit that referenced this pull request Dec 18, 2023
* fix: tiktok remove lowercasing for custom events (#2930)

* fix: email validation for braze (#2929)

* fix: addressed comments

* fix: pinterest event value is restricted to string (#2933)

* fix: converting event names to string before lowercasing

* fix: small edit and adding test cases

* fix: small edit and adding test cases

* fix: remove log from dcm_floodlight (#2934)

* chore(release): 1.52.3

---------

Co-authored-by: Anant Jain <[email protected]>
Co-authored-by: AASHISH MALIK <[email protected]>
Co-authored-by: shrouti1507 <[email protected]>
Co-authored-by: Sankeerth <[email protected]>
Co-authored-by: GitHub Actions <[email protected]>
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.

3 participants