Repository navigation
durable-objects: route on the action segment, not a substring of the path - #110
Merged
Merged
Conversation
…path A list ID starting with "add" or "show" matched the wrong branch, and /<list_id>/add without a message raised IndexError. Split the path into list ID, action and message, compare the action exactly, and answer an add without a message with the usage text. Fixes cloudflare#108.
ryanking13
approved these changes
Oct 26, 2026
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.
Fixes #108
durable-objects/src/entry.pypicked the branch with"/add" in url.pathand"/show" in url.path. So a list ID that contains/add, such as/address-book/show, took the add branch and failed withIndexErroronurl.path.split("/")[3], and/room-1/addwithout a message failed the same way.The handler now splits the path once into list ID, action and message, and compares the action exactly (
add/show). Anaddwithout a message gets the same 400 usage text as a request without a list ID. Unknown actions still get 404.I didn't run it under
pywrangler dev. I loadedentry.pywith stubworkersandpyodide.ffimodules and an in-memory storage, then calledDefault.fetch:/address-book/showIndexErrorNo messages/address-book/add/hiMessage sentMessage sent/address-book/show(after the add)IndexErrorhi/room-1/addIndexError/room-1/showNo messagesNo messages//x/otherruff 0.16.8 (check and format) and codespell 2.4.3 from the pre-commit config are clean.
Note: I used Claude Code while working on this.