Fix list-scoped reminder endpoints: UUID resolution and route matching - #2
Open
jshiflet wants to merge 2 commits into
Open
Fix list-scoped reminder endpoints: UUID resolution and route matching#2jshiflet wants to merge 2 commits into
jshiflet wants to merge 2 commits into
Conversation
…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>
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.
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:
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.
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.
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