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: prevent error when forwarding user attributes to kits while kit … #947

Merged

Conversation

mmustafa-tse
Copy link
Contributor

…blocking enabled and unplanned UAs are allowed

Summary

  • A customer provided that an error is thrown when enabling kit blocking or user attributes in the UI and having unplanned user attributes to be allowed, this result in a conflict where dataPointMatchLookUps for user_attributes will be null since and thus when we try to look into a key of null, the error is thrown.

Testing Plan

  • [Y] Was this tested locally? If not, explain why.
  • Unit tests did not fail and E2E tested

Reference Issue (For mParticle employees only. Ignore if you are an outside contributor)

}
if (!matchedAttributes[key]) {
return true
var matchedAttributes = this.dataPlanMatchLookups['user_attributes'];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
var matchedAttributes = this.dataPlanMatchLookups['user_attributes'];
const matchedAttributes = this.dataPlanMatchLookups['user_attributes'];

return false
}

if (this.blockUserAttributes && typeof matchedAttributes === "object") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is checking this.blockUserAttributes necessary? We're already checking for it's existence a few lines earlier.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was actually thinking about that and it did seem redundant

Copy link
Member

@rmi22186 rmi22186 left a comment

Choose a reason for hiding this comment

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

There should be a test added to this that fails with the previous code, but passes with the current code.

@mmustafa-tse
Copy link
Contributor Author

@rmi22186 @alexs-mparticle - added unit test and confirmed it was passing with my code change in KitBlocking.ts and was failing when testing the old code prior to my changes

Comment on lines 629 to 630
expect(() => { kitBlocker.isAttributeKeyBlocked('unplannedAttr') }).to.not.throw(TypeError, /Cannot read properties of undefined \(reading 'unplannedAttr'\)/)

Copy link
Member

Choose a reason for hiding this comment

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

Add another expect for kitBlocker.isAttributeKeyBlocked('unplannedAttr' to equal true)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added the case and confirmed this should be expected to be false

Copy link
Member

@rmi22186 rmi22186 left a comment

Choose a reason for hiding this comment

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

minor comments, otherwise lgtm!

@mmustafa-tse mmustafa-tse requested a review from rmi22186 December 4, 2024 19:53
src/kitBlocking.ts Outdated Show resolved Hide resolved
@mmustafa-tse mmustafa-tse requested a review from rmi22186 December 4, 2024 20:19
@rmi22186 rmi22186 force-pushed the fix/dataPlanUserAttributeBlocking branch from 1879acd to f686ce7 Compare December 17, 2024 20:29
@rmi22186 rmi22186 merged commit fdbc6ba into mParticle:development Dec 17, 2024
20 of 21 checks passed
github-actions bot pushed a commit that referenced this pull request Jan 6, 2025
## [2.31.1](v2.31.0...v2.31.1) (2025-01-06)

### Bug Fixes

* Check for uploader to prevent errors when calling upload() too early ([#938](#938)) ([4342b0a](4342b0a))
* Forward user attributes to kits properly when kit blocking is enabled and unplanned UAs are allowed ([#947](#947)) ([fdbc6ba](fdbc6ba))
@mparticle-automation
Copy link
Collaborator

🎉 This PR is included in version 2.31.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

4 participants