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: Serialization of nullable booleans #2706

Merged
merged 2 commits into from
Feb 20, 2023

Conversation

philipphofmann
Copy link
Member

📜 Description

The protocol contains a couple of nullable BOOLs that are of type NSNumber. Setting these properties to something different than 0 or 1 leads to a serialized NSNumber, which violates the protocol. With this refactoring 0 value always means false, and any nonzero value is interpreted as true when serializing such nullable BOOLs.

💡 Motivation and Context

Came up while investigating issues for MetricKit, as the server complained for invalid boolean values.
Screenshot 2023-02-20 at 11 50 49

💚 How did you test it?

Unit tests.

📝 Checklist

You have to check all boxes before merging:

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

The protocol contains a couple of nullable BOOLs that are of type
NSNumber. Setting these properties to something different than 0
or 1 leads to a serialized NSNumber, which violates the protocol.
With this refactoring 0 value always means false, and any nonzero
value is interpreted as true when serializing such nullable BOOLs.
@codecov
Copy link

codecov bot commented Feb 20, 2023

Codecov Report

Merging #2706 (80e74ba) into main (72c650a) will increase coverage by 1.40%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2706      +/-   ##
==========================================
+ Coverage   79.25%   80.65%   +1.40%     
==========================================
  Files         247      247              
  Lines       22928    22939      +11     
  Branches     9955    10158     +203     
==========================================
+ Hits        18171    18501     +330     
+ Misses       4287     3974     -313     
+ Partials      470      464       -6     
Impacted Files Coverage Δ
Sources/Sentry/NSMutableDictionary+Sentry.m 100.00% <100.00%> (ø)
Sources/Sentry/SentryFrame.m 100.00% <100.00%> (ø)
Sources/Sentry/SentryMechanism.m 100.00% <100.00%> (ø)
Sources/Sentry/SentrySession.m 97.43% <100.00%> (-0.03%) ⬇️
Sources/Sentry/SentryStacktrace.m 100.00% <100.00%> (ø)
Sources/Sentry/SentryThread.m 100.00% <100.00%> (ø)
Sources/Sentry/SentryRequestOperation.m 67.56% <0.00%> (-10.82%) ⬇️
Sources/Sentry/SentryNetworkTracker.m 94.25% <0.00%> (-1.02%) ⬇️
Sources/Sentry/SentryScreenshot.m 73.52% <0.00%> (ø)
Sources/Sentry/NSDictionary+SentrySanitize.m 100.00% <0.00%> (ø)
... and 33 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 72c650a...80e74ba. Read the comment docs.

Copy link
Contributor

@brustolin brustolin left a comment

Choose a reason for hiding this comment

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

LGTM

@philipphofmann philipphofmann merged commit 63f740d into main Feb 20, 2023
@philipphofmann philipphofmann deleted the fix/serialization-nullable-booleans branch February 20, 2023 15:43
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.

2 participants