Skip to content

trash with more than one id is rejected with a 400; one at a time works #15

Description

@ergofobe

imogen trash <id> <id> … is rejected with a 400; the same ids trashed one at a time all
succeed.

$ imogen trash 99588211-… 9f3e624a-… 4784a6ba-… (11 ids)
error: The request did not match what this endpoint expects (400 validation_failed)

$ imogen trash --json 99588211-…
{ "count": 1 }

Eleven separate calls trashed all eleven. Only the multi-id form fails.

Where it is going wrong

AssetSelection in @imogen/shared refuses a body carrying both selectors:

if ((selection.assetIds === undefined) === (selection.query === undefined)) {
  return 'Provide exactly one of assetIds or query'
}

and the comment above it says this is meant to be caught client-side:

a client should learn this before the request leaves, not from a 400: every port checks
the same two rules, and the SDK's own selection helper checks them with this.

So the CLI is sending query alongside assetIds — presumably its filter options
(--type, --album, --favorite, --archived, -Q) building a query object even when
none were given and ids were. That the single-id call succeeds suggests the difference is in
how the argument list is turned into a selection, not in the ids themselves.

Whatever the mechanism, the rule was supposed to be enforced before the request left and was
not — the server's 400 is the first anyone hears of it.

Worth checking while in there

The 400 tells the user nothing. The server returns a details map naming the offending
field, and the message here is the generic envelope sentence — the same gap that made
ergofobe/imogen-android#22 undiagnosable until the client started recording details.
Surfacing it would have made this a ten-second diagnosis instead of a server-log hunt.

Environment

imogen 0.1.2 against imogen-server 0.5.1. Reproduced with 11 valid uuids belonging to
the caller.

Bar

cargo test --locked && cargo fmt --check && cargo clippy --all-targets --locked -- -D warnings && cargo build --release --locked. A test that a multi-id selection serialises to assetIds
only, with no query key, is the one that would have caught this.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions