Send filters as AssetSelection queries, chunk id-based bulk calls - #6
Merged
Merged
Conversation
trash/restore and album add enumerated every matching asset client-side
even when given a filter, then shipped the whole id list in one request
— silently broken past the server's 1000-id cap, and one round trip per
page of the library for a resolved-count confirmation prompt that didn't
need the assets themselves. They now send the filter straight through as
AssetSelection { query }, resolving just the count (from the timeline's
day buckets) to show in the prompt. Explicit id lists — the only case
that actually needs assetIds on the wire — are chunked at 500 for trash,
restore, and album add/remove, matching the chunking already used by
album add and upload's post-upload album fill.
Co-Authored-By: Claude with claude-sonnet-5
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.
Audit
Read through
src/commands/assets.rs,src/commands/albums.rs,src/commands/upload.rs,src/context.rs, andsrc/tui/againstimogen-sdkat 914e6a9 (AssetSelection { asset_ids, query, except }, server cap of 1000 ids / 10,000 except).Confirmed the reported bug on current main, plus one the audit turned up:
assets::trash(main@4ed2aa6src/commands/assets.rs:587-609) — given a--query-style filter,ctx.select()walked every matching page client-side viamatching(), collected the ids, then sent them as a singleAssetSelection::ids(&targets)call. Two problems: it enumerated instead of sending the filter asAssetSelection { query }, and the single call was never chunked, so trashing more than 1000 matches would 400 against the server's.max(1000).assets::restore(src/commands/assets.rs:623-653) — same shape: walked all trashed assets viamatching(), sent one unchunkedAssetSelection::ids(&targets)call.albums::add(src/commands/albums.rs:202-221) — also resolved a--queryfilter to ids viactx.select()instead of sending it as a selection query. It was already chunking at 500 (ids.chunks(500)), so no cap bug there, just the unnecessary enumeration.albums::remove(src/commands/albums.rs:244-259) — explicit ids only (no--queryat the CLI level), butAssetSelection::ids(assets)was sent as one unchunked call — the same 1000-cap bug as trash/restore.upload.rsand the TUI (src/tui/mod.rs) were already correct:upload.rs's post-upload album fill chunks at 500 (chunks(500)), and the TUI's trash/restore only ever act on a single selected photograph (vec![id]), so no chunking was needed there.assets::editenumerates client-side by necessity — there is no bulk-editAssetSelection-based SDK endpoint, only per-assetPATCH, so this one is inherent to the API surface and was left unchanged.Changes
Context::to_filter(src/context.rs) — new helper building anAssetFilterfromQueryArgs, alongside aContext::counthelper that resolves a filter's match count from the timeline's day buckets (one request, no page walk — the same technique the TUI already uses for its header count).Context::to_querynow builds onto_filterrather than duplicating every field.assets::trash/assets::restore— explicit ids are chunked at 500 and sent asAssetSelection::ids; a filter is resolved to a count for the confirmation prompt (Move 12,431 photographs to the trash?, never "all photos") and sent asAssetSelection { query: Some(filter) }in a single request, sidestepping the per-id cap entirely.albums::add— same split: explicit--assetids chunked at 500 as before; a--queryfilter now goes through asAssetSelection { query }after a cheap count check for "Nothing matched."albums::remove— chunked at 500, closing the cap bug.-y/--yesbehavior is unchanged: it skips the prompt but the resolved count still prints in the final summary either way.Verification
cargo fmt --checkcargo build --all-targetscargo clippy --all-targets -- -D warningscargo test— 103 passed, 2 ignored (pre-existing, marked "for looking at, not for CI")Tracking issues filed (not implemented here)
Co-Authored-By: Claude with claude-sonnet-5