[PR #22838] [CLOSED] fix: deduplicate notes in pagination to prevent each_key_duplicate error #130542

Closed
opened 2026-05-21 14:49:55 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/22838
Author: @themavik
Created: 3/19/2026
Status: Closed

Base: mainHead: fix/22740-notes-duplicate-key-infinite-scroll


📝 Commits (1)

  • 473546f fix: deduplicate notes in pagination to prevent each_key_duplicate error

📊 Changes

1 file changed (+3 additions, -1 deletions)

View changed files

📝 src/lib/components/notes/Notes.svelte (+3 -1)

📄 Description

Summary

Fixes #22740.

Root cause: getItemsPage() in Notes.svelte appends pageItems to items with items = [...items, ...pageItems] without deduplication. When the API returns overlapping notes across pages (e.g., due to concurrent note creation shifting pagination offsets), the same note.id appears at multiple array indices. Svelte's keyed {#each notesList as note, idx (note.id)} then throws each_key_duplicate, breaking infinite scroll.

Fix: Before appending, build a Set of existing note IDs and filter out any duplicates from the new page.

Changes

  • src/lib/components/notes/Notes.svelte: In getItemsPage(), deduplicate pageItems against existing items by note.id before concatenation.

Testing

  • Verified fix prevents duplicate key errors when API returns overlapping notes across pages
  • Change is minimal (3 lines) and follows existing code patterns
  • No behavioral change for non-overlapping pagination responses

Made with Cursor


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/22838 **Author:** [@themavik](https://github.com/themavik) **Created:** 3/19/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/22740-notes-duplicate-key-infinite-scroll` --- ### 📝 Commits (1) - [`473546f`](https://github.com/open-webui/open-webui/commit/473546ffafdf15cd9bd84b37277c65cc64e4760f) fix: deduplicate notes in pagination to prevent each_key_duplicate error ### 📊 Changes **1 file changed** (+3 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/lib/components/notes/Notes.svelte` (+3 -1) </details> ### 📄 Description ## Summary Fixes #22740. **Root cause:** `getItemsPage()` in `Notes.svelte` appends `pageItems` to `items` with `items = [...items, ...pageItems]` without deduplication. When the API returns overlapping notes across pages (e.g., due to concurrent note creation shifting pagination offsets), the same `note.id` appears at multiple array indices. Svelte's keyed `{#each notesList as note, idx (note.id)}` then throws `each_key_duplicate`, breaking infinite scroll. **Fix:** Before appending, build a `Set` of existing note IDs and filter out any duplicates from the new page. ## Changes - `src/lib/components/notes/Notes.svelte`: In `getItemsPage()`, deduplicate `pageItems` against existing `items` by `note.id` before concatenation. ## Testing - Verified fix prevents duplicate key errors when API returns overlapping notes across pages - Change is minimal (3 lines) and follows existing code patterns - No behavioral change for non-overlapping pagination responses Made with [Cursor](https://cursor.com) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-21 14:49:55 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#130542