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

Handle crash in Bulk Order Update when item position is -1 #13359

Merged
merged 1 commit into from
Jan 21, 2025

Conversation

hafizrahman
Copy link
Contributor

@hafizrahman hafizrahman commented Jan 21, 2025

Closes: #13358

Description

I can't reproduce the issue reported in the linked Sentry issue. The docs for getBindingAdapterPosition says:

The adapter position of the item if it still exists in the adapter. NO_POSITION if item has been removed from the adapter, notifyDataSetChanged has been called after the last layout pass or the ViewHolder has already been recycled.

Nevertheless, since it's a possibility that viewHolder.bindingAdapterPosition returns RecyclerView.NO_POSITION which is equal to -1, this PR adds handling for that by simply returning null when that happens. This makes the selection not happen on the item with no position, but it won't crash anymore.

Steps to reproduce

Since I'm not sure how to test the issue, it's probably good to smoke test the bulk update order feature to ensure that it still works after this PR.

Testing information

n/a

The tests that have been performed

Smoke-tested the feature to ensure it still works with the changes in this PR.

Images/gif

  • I have considered if this change warrants release notes and have added them to RELEASE-NOTES.txt if necessary. Use the "[Internal]" label for non-user-facing changes.

Reviewer (or Author, in the case of optional code reviews):

Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement:

  • The PR is small and has a clear, single focus, or a valid explanation is provided in the description. If needed, please request to split it into smaller PRs.
  • Ensure Adequate Unit Test Coverage: The changes are reasonably covered by unit tests or an explanation is provided in the PR description.
  • Manual Testing: The author listed all the tests they ran, including smoke tests when needed (e.g., for refactorings). The reviewer confirmed that the PR works as expected on big (tablet) and small (phone) in case of UI changes, and no regressions are added.

@hafizrahman hafizrahman changed the base branch from trunk to release/21.4 January 21, 2025 14:04
@hafizrahman hafizrahman added the type: crash The worst kind of bug. label Jan 21, 2025
@dangermattic
Copy link
Collaborator

dangermattic commented Jan 21, 2025

1 Warning
⚠️ This PR is assigned to the milestone 21.4 ❄️. The due date for this milestone has already passed.
Please assign it to a milestone with a later deadline or check whether the release for this milestone has already been finished.

Generated by 🚫 Danger

@hafizrahman hafizrahman added this to the 21.4 ❄️ milestone Jan 21, 2025
@hafizrahman hafizrahman force-pushed the issue/13358-handle-no-position branch from cfe5417 to 2d4a970 Compare January 21, 2025 14:10
@wpmobilebot
Copy link
Collaborator

📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
App Name WooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commit2d4a970
Direct Downloadwoocommerce-wear-prototype-build-pr13359-2d4a970.apk

@hafizrahman hafizrahman marked this pull request as ready for review January 21, 2025 14:23
@hichamboushaba hichamboushaba self-assigned this Jan 21, 2025
@wpmobilebot
Copy link
Collaborator

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App Name WooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commit2d4a970
Direct Downloadwoocommerce-prototype-build-pr13359-2d4a970.apk

@codecov-commenter
Copy link

codecov-commenter commented Jan 21, 2025

Codecov Report

Attention: Patch coverage is 0% with 9 lines in your changes missing coverage. Please review.

Project coverage is 40.80%. Comparing base (438ecaf) to head (2d4a970).
Report is 2 commits behind head on release/21.4.

Files with missing lines Patch % Lines
...ce/android/ui/orders/DefaultOrderListItemLookup.kt 0.00% 9 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##             release/21.4   #13359   +/-   ##
===============================================
  Coverage           40.80%   40.80%           
  Complexity           6411     6411           
===============================================
  Files                1353     1353           
  Lines               77679    77678    -1     
  Branches            10692    10692           
===============================================
  Hits                31698    31698           
+ Misses              43172    43171    -1     
  Partials             2809     2809           

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

Copy link
Member

@hichamboushaba hichamboushaba left a comment

Choose a reason for hiding this comment

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

Changes look good and make sense, I tested the feature and didn't notice any regression, thanks for the quick fix @hafizrahman

@hichamboushaba hichamboushaba merged commit cf90e04 into release/21.4 Jan 21, 2025
22 checks passed
@hichamboushaba hichamboushaba deleted the issue/13358-handle-no-position branch January 21, 2025 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: crash The worst kind of bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IndexOutOfBoundsException: Index: -1, Size: 62
5 participants