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: Type hinting MPIdentityApiRequest.identities #270

Merged
merged 1 commit into from Apr 17, 2024

Conversation

einsteinx2
Copy link
Contributor

Summary

Fix crash when accessing the -[MPIdentityApiRequest identity] property from Swift due to incorrect type hinting

We had it hinted as <NSNumber*, NSString*> but then we also stored NSNull objects in some cases. That was fine with Objective-C since it ignores the type hints at runtime, but Swift doesn't and crashes if any NSNull objects are present when accessing the identities property.

Note this doesn't actually change the underlying behavior of this property in any way, it just now is correctly type hinted as <NSNumber*, NSObject*> to include the possibility of NSNull.

Testing Plan

  • Was this tested locally? If not, explain why.
  • First reproduced the crash, then confirmed that I can now access the property from Swift without crashing. Also added unit tests to confirm both the core behavior and the Swift interop, explicitly accessing the property from Swift when it contains an NSNull object.

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

Copy link
Contributor

@BrandonStalnaker BrandonStalnaker left a comment

Choose a reason for hiding this comment

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

LGTM

@einsteinx2 einsteinx2 merged commit f56879f into development Apr 17, 2024
11 checks passed
@einsteinx2 einsteinx2 deleted the fix/6338-MPIdentityApiRequest-swift-interop branch April 17, 2024 14:31
mparticle-automation added a commit that referenced this pull request Apr 17, 2024
## [8.21.1](v8.21.0...v8.21.1) (2024-04-17)

### Bug Fixes

* Type hinting MPIdentityApiRequest.identities ([#270](#270)) ([f56879f](f56879f))
@mparticle-automation
Copy link
Contributor

🎉 This PR is included in version 8.21.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

None yet

3 participants