Skip to content

fix: Prevent IndexOutOfBoundsException in paging by enforcing item ID uniqueness#20

Merged
romychab merged 1 commit into
mainfrom
fix/paged-list-index-out-of-bounds
Jul 3, 2026
Merged

fix: Prevent IndexOutOfBoundsException in paging by enforcing item ID uniqueness#20
romychab merged 1 commit into
mainfrom
fix/paged-list-index-out-of-bounds

Conversation

@romychab

@romychab romychab commented Jul 3, 2026

Copy link
Copy Markdown
Owner

ListMerger.reorderNonFinalItems assumed a 1:1 correspondence between target-list positions matching newIds and the new-item anchors. Duplicate item IDs (within a page, the same item across pages with live pagination, or externally intercepted values) broke that invariant and crashed with "Index N out of bounds for length N".

Deduplicate by itemId at every point that produces the output list (getNonFinalItems, ListMerger input/result, and intercept), and guard the reorder loop, so the emitted list always has unique IDs. This also avoids Compose LazyColumn/LazyRow key-collision crashes downstream.

… uniqueness

ListMerger.reorderNonFinalItems assumed a 1:1 correspondence between target-list positions matching newIds and the new-item anchors. Duplicate item IDs (within a page, the same item across pages with live pagination, or externally intercepted values) broke that invariant and crashed with "Index N out of bounds for length N".

Deduplicate by itemId at every point that produces the output list (getNonFinalItems, ListMerger input/result, and intercept), and guard the reorder loop, so the emitted list always has unique IDs. This also avoids Compose LazyColumn/LazyRow key-collision crashes downstream.
@romychab
romychab merged commit 512d45d into main Jul 3, 2026
4 checks passed
@romychab
romychab deleted the fix/paged-list-index-out-of-bounds branch July 3, 2026 17:54
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.

1 participant