Conversation
|
Claude finished @nollymar's task in 3m 38s —— View job PR Review
The core fix (always resolve ensure items from Bug 1 — Offset drift when the ensure item sits inside a later page's DB batch
Concrete example with
This triggers whenever Bug 2 — Offset over-adjusted when the ensure item is already in page 1's natural range
Concrete example with
The adjustment should only subtract the count of ensure items whose natural positions are below Minor: Tests don't cover the edge cases aboveAll three ensure tests use items at positions 5 or 4–5 of 7 with
The reported regression is fixed for the production scenario (dotAsset/FileAsset late in the sort order), but the offset math remains fragile for edge cases. Unrelated: removal of
|
…set-duplicate-in-content-type-filter-after-reload-and-become-unselectable
…set-duplicate-in-content-type-filter-after-reload-and-become-unselectable
…set-duplicate-in-content-type-filter-after-reload-and-become-unselectable
Content type id and inode are the same value, so tracking both in includedIds was redundant. Removed duplicate inode() calls in favor of id() only. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…set-duplicate-in-content-type-filter-after-reload-and-become-unselectable
What's the problem?
The
/api/v1/contenttypeendpoint supports anensureparameter — a way to guarantee that a specific content type appears in the first page of results, even if it wouldn't land there in normal alphabetical order. Content Drive uses this so that when you reload the page with a content type already selected in the URL (e.g.?filters=contentType:dotAsset), the multiselect dropdown can immediately show your pre-selected item.The problem: the pagination math didn't account for the slot that the
ensureitem "borrowed" from page 1. This caused two bugs at once:Bug 1 — The ensured item appears twice
Consider 7 content types sorted alphabetically and a request for 3 per page with
ensure=FileAsset(which naturally lives at position 5):[Blog, DotAsset, FileAsset][Blog, DotAsset, FileAsset]✅[Generic, News, Product][Generic, News, FileAsset]❌ FileAsset again![Widget][Widget]✅Bug 2 — A content type goes missing forever
Because
FileAssetwas "borrowed" to page 1, it displaced the item that should have been in the 3rd slot. That item —Genericin the example — gets pushed to page 2. But the offset for page 2 was never adjusted, so the database query skips right over it:So after scrolling through the entire list,
FileAssetshowed up twice andGenericnever appeared at all.Root Cause
Both bugs trace back to two lines in
ContentTypeAPIImpl.search():Problem 1 — The ensure item lookup was called with the client's offset:
Problem 2 — The normal paginated query used the raw client offset, unaware that page 1 had "borrowed" a slot:
The Fix
Three targeted changes in
ContentTypeAPIImpl.search():offset=0— their IDs are needed every time to build the exclusion list for the normal query.offset == 0) — subsequent pages don't re-include them.ensureCountfrom the offset on pages 2+ — this shifts the window back so the displaced item is no longer skipped.Result with the fix:
All 7 items returned exactly once.
Proposed Changes
ContentTypeAPIImpl.search()— fix ensure item lookup offset, gate page-1-only inclusion, apply adjusted offset to normal paginated queryAdditional Info
This fix covers the single base-type path (the path taken by Content Drive when no base-type filter is active — the scenario that triggered the original bug report). The multi-type UNION path (
ContentTypeFactoryImpl.searchMultipleTypes) has analogous code and the same latent bugs, but it is only reached when multiple base-type filters are selected simultaneously — a separate, lower-priority follow-up.Videos
Issue
video.mov
Fix
video.mov
This PR fixes: #35213