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

[Bug] Null check and return false if null. #20855

Closed
wants to merge 1 commit into from

Conversation

notandyvee
Copy link
Contributor

@notandyvee notandyvee commented May 20, 2024

Fixes Sentry Issue - Github Issue

This crash is happening because we are using the !! bang operator to unsafely use a possibly nullable variable. Even if the expectation is to not have a null, crashing isn't the answer. So returning false in case it is null. I took a look at how isPage is being used, which is the source of the crash. And it's used to decide the height of the bottom sheet. I can't reproduce the issue.

An alternative solution here could be to just not allow a publish bottom sheet to show. This could be good because the post loading could be a result of a race condition.


To Test:

  • Go to post list and drafts
  • Click the overflow menu item on the right.
  • Click publish
  • Publish the post.
  • If we made it here we are good to go.

Regression Notes

  1. Potential unintended areas of impact

    If the post is null, allowing a publish could be problematic. We don't use the post for anything else. So I can't see how it could be an issue. But is a possibility.

  2. What I did to test those areas of impact (or what existing automated tests I relied on)

    Manual test.

  3. What automated tests I added (or what prevented me from doing so)

    None.


PR Submission Checklist:

  • I have completed the Regression Notes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

Testing Checklist (strike-out the not-applying and unnecessary ones):

  • WordPress.com sites and self-hosted Jetpack sites.
  • Portrait and landscape orientations.
  • Light and dark modes.
  • Fonts: Larger, smaller and bold text.
  • High contrast.
  • Talkback.
  • Languages with large words or with letters/accents not frequently used in English.
  • Right-to-left languages. (Even if translation isn’t complete, formatting should still respect the right-to-left layout)
  • Large and small screen sizes. (Tablet and smaller phones)
  • Multi-tasking: Split screen and Pop-up view. (Android 10 or higher)

@notandyvee notandyvee added this to the 25.0 milestone May 20, 2024
@notandyvee notandyvee requested a review from zwarm May 20, 2024 22:39
Copy link

sonarcloud bot commented May 20, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@wpmobilebot
Copy link
Contributor

WordPress📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress WordPress
FlavorJalapeno
Build TypeDebug
Versionpr20855-5165d1f
Commit5165d1f
Direct Downloadwordpress-prototype-build-pr20855-5165d1f.apk
Note: Google Login is not supported on these builds.

@wpmobilebot
Copy link
Contributor

Jetpack📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack Jetpack
FlavorJalapeno
Build TypeDebug
Versionpr20855-5165d1f
Commit5165d1f
Direct Downloadjetpack-prototype-build-pr20855-5165d1f.apk
Note: Google Login is not supported on these builds.

Copy link

codecov bot commented May 20, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 40.70%. Comparing base (595f399) to head (5165d1f).
Report is 488 commits behind head on trunk.

Files Patch % Lines
...g/wordpress/android/ui/posts/EditPostRepository.kt 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            trunk   #20855      +/-   ##
==========================================
- Coverage   40.70%   40.70%   -0.01%     
==========================================
  Files        1498     1498              
  Lines       68759    68759              
  Branches    11366    11367       +1     
==========================================
- Hits        27986    27985       -1     
  Misses      38240    38240              
- Partials     2533     2534       +1     

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

@notandyvee
Copy link
Contributor Author

@zwarm just bumping incase you missed it. Let me know if you can't review.

@notandyvee notandyvee requested a review from aditi-bhatia May 23, 2024 21:37
@notandyvee
Copy link
Contributor Author

Hey @aditi-bhatia sorry for pinging you. If you have time to review, that would be great.

@oguzkocer oguzkocer modified the milestones: 25.0, 25.1 May 27, 2024
Copy link
Contributor

@aditi-bhatia aditi-bhatia left a comment

Choose a reason for hiding this comment

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

I agree that we shouldn't be using the !! operator but I see every variable in this file using it. I'm concerned that the crash will just happen later down the line with one of the other variables instead, so maybe we should be updating all of these? I know that might increase the scope of this ticket here so curious to hear your thoughts

@aditi-bhatia
Copy link
Contributor

Hey @aditi-bhatia sorry for pinging you. If you have time to review, that would be great.

Sorry I definitely didn't see the notification for this 😅 Thanks for the Slack reminder today!

@notandyvee notandyvee added the [Status] Needs Discussion The issue needs to be discussed by the team before it can be resolved. label Jun 4, 2024
@notandyvee
Copy link
Contributor Author

@aditi-bhatia It's ok. There are related issues here. I've attempted to reproduce but cannot. Removing the bang operators is easy. The hard part are the changed to all usages. And it's a good amount of them 😅 . I can't reproduce the issue, which makes the decision difficult. I'll circle back here in a few days.

@aditi-bhatia
Copy link
Contributor

Sounds good, I tried reproducing but couldn't either. Let me know what you decide / when you'd like me to take a look again 👍

@notandyvee
Copy link
Contributor Author

Decided to close this PR as another bigger crash would likely fix this here. Small enough change here where it's fine to close. Sorry for the wasted time 😅

@notandyvee notandyvee closed this Jun 5, 2024
@jkmassel jkmassel deleted the andy/sentry-issue-5274347067 branch October 17, 2024 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Status] Needs Discussion The issue needs to be discussed by the team before it can be resolved. [Type] Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants