Skip to content

fix: email validation for braze - #2929

Merged
aashishmalik merged 2 commits into
hotfix/Dec.18from
fix/braze-email
Dec 18, 2023
Merged

aashishmalik merged 2 commits into
hotfix/Dec.18from
fix/braze-email

Conversation

@aashishmalik

@aashishmalik aashishmalik commented Dec 18, 2023 •

Copy link
Copy Markdown
Contributor

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 ItsSudip and krishna2020 and removed request for a team December 18, 2023 04:43
@coderabbitai

coderabbitai Bot commented Dec 18, 2023

Copy link
Copy Markdown
Contributor

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
@codecov

codecov Bot commented Dec 18, 2023 •

Copy link
Copy Markdown

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.

Comment thread src/v0/destinations/braze/transform.js Outdated
// 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)) {

@koladilip koladilip Dec 18, 2023 •

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.

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?

@aashishmalik aashishmalik Dec 18, 2023 •

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

updated

@sonarqubecloud

Copy link
Copy Markdown

Comment thread src/v0/destinations/braze/transform.js Resolved
"_update_existing_only": false,
"city": "Disney",
"country": "USA",
"email": null,

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.

Email is still coming as null

Copy link
Copy Markdown
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.

@aashishmalik aashishmalik Dec 18, 2023 •

Copy link
Copy Markdown
Contributor Author

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
@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