Skip to content

Fix list-scoped reminder endpoints: UUID resolution and route matching - #2

Open
jshiflet wants to merge 2 commits into
cromulus:mainfrom
jshiflet:jshiflet/item-update-failure-fixes
Open

Fix list-scoped reminder endpoints: UUID resolution and route matching#2
jshiflet wants to merge 2 commits into
cromulus:mainfrom
jshiflet:jshiflet/item-update-failure-fixes

Conversation

@jshiflet

Copy link
Copy Markdown

The Home Assistant integration references lists and reminders by their
exposed UUIDs and updates items via PATCH /lists/:listName/reminders/:id,
but every list-scoped call failed. Debugging the integration end to end
surfaced three independent defects in the REST server:

  1. List lookups were name-only and crashed on a miss.
    The list-scoped helpers resolved the calendar with calendar(withName:),
    so a UUID in the path never matched a list, and a missing list aborted
    the process instead of returning an error — surfacing to clients as
    "Server disconnected" / 502. Added resolveListCalendar(), which tries
    the calendar identifier (UUID) first, then a case-insensitive title
    match, and throws 404 on a miss. Lists can now be addressed by name or
    UUID, and a bad value can no longer take the server down.

  2. Per-reminder lookups matched on the wrong identifier.
    delete / complete / uncomplete / update compared the path id against
    calendarItemExternalIdentifier, but the API exposes (and clients round-
    trip) uuid/externalId, which equals calendarItemIdentifier — a different
    value — so every list-scoped mutation returned 404 "Reminder not found."
    Added a shared resolveReminder() that looks the reminder up via
    getReminderByUUID() first (matching the canonical /reminders/:uuid
    routes) and falls back to the legacy external-identifier scan. Routed
    delete, setReminderComplete and updateReminder through it, and taught
    the update path to honor isCompleted.

  3. A parameter-name collision made the nested routes unreachable.
    The list segment was registered as :name on GET/POST and :listName on
    DELETE/PATCH. Hummingbird keys the routing trie by parameter name, so it
    built two separate nodes at lists/; requests resolved into the
    :name node (which only carried GET and POST) while the entire
    reminders/:id subtree lived on the orphaned :listName node and was never
    reached — producing empty-body 404s before any handler ran.
    Standardized the segment to :listName on every route and updated the
    GET/POST handlers to read it, so one node carries the whole subtree.

With all three fixed, create/read/update/delete and complete/uncomplete
resolve by name or UUID and the integration's updates succeed.

Co-authored-by: Claude noreply@anthropic.com

jshiflet and others added 2 commits June 15, 2026 19:46
…ome Assistant integration

When creating a to-do item in Home Assistant, the ha-reminders-cli integration will error with one of two errors
- Error during service call to todo.add_item: Failed to create reminder: Server disconnected
- Error during service call to todo.add_item: Failed to create reminder: 502, message='Bad Gateway', url='https://[reverseProxyURL:port]/api/lists/[listName]/reminders'

This also causes the reminders-api process to crash on the macOS device with the following backtrace:
- NullDecoder.decode(...)
  CodableProtocols.swift:48
  preconditionFailure("HBApplication.decoder has not been set")

Adding middleware JSON decoder resolves the base crash problem and allows the to-do item to be created

Co-authored-by: codex <codex@openai.com>
The Home Assistant integration references lists and reminders by their
exposed UUIDs and updates items via PATCH /lists/:listName/reminders/:id,
but every list-scoped call failed. Debugging the integration end to end
surfaced three independent defects in the REST server:

1. List lookups were name-only and crashed on a miss.
   The list-scoped helpers resolved the calendar with calendar(withName:),
   so a UUID in the path never matched a list, and a missing list aborted
   the process instead of returning an error — surfacing to clients as
   "Server disconnected" / 502. Added resolveListCalendar(), which tries
   the calendar identifier (UUID) first, then a case-insensitive title
   match, and throws 404 on a miss. Lists can now be addressed by name or
   UUID, and a bad value can no longer take the server down.

2. Per-reminder lookups matched on the wrong identifier.
   delete / complete / uncomplete / update compared the path id against
   calendarItemExternalIdentifier, but the API exposes (and clients round-
   trip) uuid/externalId, which equals calendarItemIdentifier — a different
   value — so every list-scoped mutation returned 404 "Reminder not found."
   Added a shared resolveReminder() that looks the reminder up via
   getReminderByUUID() first (matching the canonical /reminders/:uuid
   routes) and falls back to the legacy external-identifier scan. Routed
   delete, setReminderComplete and updateReminder through it, and taught
   the update path to honor isCompleted.

3. A parameter-name collision made the nested routes unreachable.
   The list segment was registered as :name on GET/POST and :listName on
   DELETE/PATCH. Hummingbird keys the routing trie by parameter name, so it
   built two separate nodes at lists/<param>; requests resolved into the
   :name node (which only carried GET and POST) while the entire
   reminders/:id subtree lived on the orphaned :listName node and was never
   reached — producing empty-body 404s before any handler ran.
   Standardized the segment to :listName on every route and updated the
   GET/POST handlers to read it, so one node carries the whole subtree.

With all three fixed, create/read/update/delete and complete/uncomplete
resolve by name or UUID and the integration's updates succeed.

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant