Archive and unarchive answer 500 for expected refusals instead of 404/409

Open
#196 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
66/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust

Research direction

Start with concert-tracker/src/web/handlers.rs, reading concert_command_error, archive_endpoint_error, and the archive and unarchive handlers. Then inspect the named handler tests and hurl/archive_lifecycle.hurl; check the documented HTMX behavior for refused requests. Done means refusals return 404 or 409, operational failures remain 500, tests cover the refusals and HTMX outcome, and refusals do not log at ERROR.

Written by the indexing model from the issue text.

Description

bug

Summary

Archive and unarchive answer 500 for every expected refusal, while every other
commanded endpoint answers the typed status its rejection names (404, 409, 422).
A user clicking Archive with no archive location configured — or Unarchive on a
concert that is not archived — is reported as a server fault: the response is
500, AppError::Internal logs it at ERROR, and the log line reads
archive location is not configured where a client error belongs.

Found while implementing #167
(PR #195), where the
interface started returning typed rejections for both routes. The mapping was
deliberately left alone there and recorded as a non-change; this issue is the
follow-up.

Where it comes from

concert-tracker/src/web/handlers.rs has two rejection mappings:

  • concert_command_error (line ~679) — NotFound → 404, Conflict → 409,
    a missing split source → 422, SourceNotRedundant → 409. Used by the other
    commands.
  • archive_endpoint_error (line ~1751) — every CommandRejection →
    AppError::Internal → 500. Used by archive and unarchive only.

The refusals that reach it are ordinary domain outcomes, not faults:

Route Refusal
POST /concerts/{id}/archive no archive location configured (Conflict)
POST /concerts/{id}/archive no such concert (NotFound)
POST /concerts/{id}/unarchive not archived, no album, or an archive in flight (Conflict)
POST /concerts/{id}/unarchive no such concert (NotFound)

ConcertCommandError::Operational genuinely is a 500; only the Rejected arm is
wrong.

Why it matters

  • The interface rejects before a client is offered an action, so a refusal here
    means a stale page or a configuration gap, not an outage. Reporting it as a 5xx
    makes real failures harder to see.
  • AppError::Internal logs every such refusal at ERROR.
  • The planned JSON adapter inherits the inconsistency: the same refusal is a 409
    for request_download and a 500 for request_archive.

What pins today's behavior (must be updated with the fix)

  • hurl/archive_lifecycle.hurl expects HTTP 500 in three places:
    archive_without_a_configured_location_is_the_endpoints_own_500 (~line 40),
    unarchiving_what_is_not_archived_keeps_the_endpoints_own_500 (~line 139),
    a_missing_concert_is_also_this_endpoints_500 (~line 165).
  • concert-tracker/src/web/handlers.rs:
    archiving_what_cannot_be_archived_is_this_endpoints_own_500 and
    unarchiving_what_is_not_archived_is_this_endpoints_own_500.
  • docs/change/2026-11-12-archive-and-unarchive-workflows.md ("Deliberate
    non-changes"), plus any route documentation that records the 500s.

Acceptance criteria

  • archive and unarchive map Rejected through the same mapping the other
    commands use, so a refusal answers the status its CommandRejection names —
    404 for an absent concert, 409 for a state conflict.
  • Operational still answers 500.
  • archive_endpoint_error is gone, or reduced to its operational arm, so a
    third copy of the mapping cannot appear.
  • The three hurl expectations and the two handler tests assert the new
    statuses, and the hurl file still covers every refusal it covers now.
  • HTMX behavior is verified, not assumed: htmx does not swap on a 4xx by
    default, so confirm what the user sees for a refused archive and unarchive
    now that the status changed (error toast, no-op, or an hx-target-error
    swap) and record it.
  • Neither route writes an ERROR log line for a refusal.
Dominant language
Rust
Stars
0
Forks
0
Avg merge
2h
Merged PRs (30d)
14

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from gregwebs/tiny-desk-splitter

All issues in gregwebs/tiny-desk-splitter

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.