Skip to content

An empty --album matches every album, and trashing by album acts on all of them #38

Closed

Description

@ergofobe

Symptom

find_album has the same empty-reference hole #30 closed in find_person, with a worse blast
radius, and two neighbouring defects that mean it cannot be fixed alone.

1. --album "" matches every album. An empty string survives QueryArgs::is_empty() — it is
Some(""), not None — so contains("") matches everything and a single-album library resolves
silently. That reaches:

imogen trash --album "$ALBUM"

with the variable unset: exit 0, and a library's worth of photographs in the trash. find_album also
does not trim, so " " behaves the same way.

2. album_or_create matches on Err(_). An ambiguous name therefore creates a duplicate
album rather than refusing. This is why the guard above cannot go in by itself: find_album("")
starting to refuse would make this path create an album literally named "".

3. The exact-name tier is not uniqueness-checked, and album names have no unique index. With two
albums called "Holiday", imogen trash --album Holiday picks whichever the server listed first.

Reproduction

  1. imogen trash --album "" — or with an unset shell variable — against a library with one album.
  2. Everything in that album is trashed, exit 0.

Expected

All three together:

  • find_album trims and refuses an empty or whitespace-only reference, before anything reaches the
    wire.
  • album_or_create distinguishes "not found" from "ambiguous", and creates only on the first.
  • The exact-name shortcut is taken only when that whole name is unique, falling through to the
    existing ambiguity refusal otherwise.

That third point has prior art worth reading: the same shortcut was attempted for people in the PR
closing #30 and reintroduced the bug it was closing, because names are not unique. Review caught
it as a blocker. Do not lift it unguarded.

Affected repos

Only this one. Nothing on the wire changes.

Context

Found by review while closing #30 and #32. Not fixed there because (2) means the guard cannot land
alone, and the three together are a different change from the people-lookup fix.

Related: imogen album update -d "new text" --clear-description is #32's contradiction in another
command — AlbumArgs::Update declares no conflicts_with. Worth fixing in the same pass since it is
the same shape.

Activity

  1. added
    bugSomething isn't working
    triagedHome repo decided, labelled, ready to bundle
    on Sep 15, 2026
  2. ergofobe commented on Sep 16, 2026

    @ergofobe
    OwnerAuthor

    Fixed by #42, merged as 4a3cc7a.

    All three together, as the issue argued they had to be. albums_for trims the reference
    and refuses an empty one before anything reaches the wire; named_album is the exact tier
    both lookups share — an id, or a name exactly one album carries, so two called "Holiday"
    are refused rather than resolved to whichever the server listed first — and
    album_or_create now acts only on that, creating for a name nothing carries and
    propagating an ambiguity or a failed listing instead of treating every Err as "not there
    yet".

    The exact-name shortcut is guarded the way #30's was, and the refusals name each album with
    its id, since the names are what was ambiguous.

    One thing changed from the issue's shape after review: album_or_create does not use the
    partial-name tier at all. Routing creation through it made a name impossible to have —
    "Holiday" beside "Holiday 2024" and "Holiday 2025" was refused as ambiguous — and where it
    did resolve it filed photographs into an album nobody named. Filing into an album is a
    name, not a search.

    Two findings from that review are filed rather than fixed here: #41 (album update -d
    with --clear-description, the contradiction this issue's Context named) and #43 (album create "" writes a name no lookup can reach).

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

    bugSomething isn't workingtriagedHome repo decided, labelled, ready to bundle

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions