fix(file-picker): apply imageOnly filtering server-side on the default list path - #6091
Open
pedrofrxncx wants to merge 1 commit into
Open
fix(file-picker): apply imageOnly filtering server-side on the default list path#6091pedrofrxncx wants to merge 1 commit into
pedrofrxncx wants to merge 1 commit into
Conversation
…t list path listObjects already filters imageOnly server-side in the search scan path (matchScanPage), but the default (no-search) path -- the month-shard probes, the broad fallback, and the cursor page via finalize() -- accepted the imageOnly param and silently ignored it, returning every key regardless of type. The client (file-picker-dialog.tsx) re-filters with its own isImageKey before rendering, so this wasn't a correctness bug, but it meant an image-only picker's page of target keys could be mostly non-images that get thrown away client-side, undercounting real images per page and forcing extra "Load more" round trips for buckets with few images. Filter server-side in all three non-search code paths, same as the existing search path, so an image-only page actually returns up to target images.
pedrofrxncx
enabled auto-merge (squash)
August 14, 2026 14:49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follows #6087 (month-shard probing) in
apps/api/src/file-storage/file-config-s3.ts— while reading it for post-merge hardening I foundlistObjects'simageOnlyparam was only honored on the search scan path (searchObjects/matchScanPage); the default (no-search) path — the month-shard probes, the broad fallback, and the cursor page viafinalize()— acceptedimageOnlyand silently ignored it, returning every key type regardless.Why it matters: the web file-picker (
file-picker-dialog.tsx) re-filters client-side with its ownisImageKey, so this wasn't a wrong-result bug, but it meant an image-only picker's page oftargetkeys could be mostly non-images that the client immediately discards — undercounting real images per page and forcing extra "Load more" round trips on buckets with a low image ratio. The doc comment onisImageKeyalready states server-side filtering matters "so the scan doesn't waste budget on rows the client throws away" — that reasoning applies equally to the default path, it just wasn't wired up there.Fix: apply the same
isImageKeyfilter used inmatchScanPageto all three non-search code paths (month-shard merge, broad fallback merge, andfinalize()for cursor pages), so an image-only request actually returns up totargetimages per page instead of relying entirely on client-side discarding.Reviewer check:
bun test apps/api/src/file-storage/file-config-s3.test.ts(27 pass, unchanged —listObjectsitself isn't unit-tested per this file's existing pattern, since it requires a live/mockedS3Client; the filtering logic is the sameisImageKeypredicate already covered by theisImageKeyandmatchScanPagedescribe blocks).Locally ran:
bun run fmt,cd apps/api && bunx tsc --noEmit(clean),bunx oxlint apps/api/src/file-storage/file-config-s3.ts(0 warnings/errors), and the targeted test file above. Full CI validates the rest.Net diff: +7/-1, one file, one concern.
Summary by cubic
Applies server-side
imageOnlyfiltering on the defaultlistObjectspath so image-only requests return up totargetimages across all code paths. Previously,imageOnlywas only honored on the search scan path; the default path ignored it and returned mixed keys, causing underfilled image pages and extra “Load more” requests.Review notes
isImageKeypredicate to month-shard merges, the broad fallback, andfinalize()cursor pages.imageOnlyis false; when true, non-image keys are skipped andtargetnow counts images rather than all keys.Written for commit 54c6585. Summary will update on new commits.