fix: allow multi-segment paths in userdata API routes#12468
Open
Peuqui wants to merge 1 commit intoComfy-Org:masterfrom
Open
fix: allow multi-segment paths in userdata API routes#12468Peuqui wants to merge 1 commit intoComfy-Org:masterfrom
Peuqui wants to merge 1 commit intoComfy-Org:masterfrom
Conversation
Change aiohttp route parameters from {file} to {file:.*} to allow
paths containing slashes (e.g. workflows/my-workflow.json).
The {file} parameter only matches a single path segment, causing 404
errors when the frontend requests files in subdirectories via
/userdata/workflows/filename.json instead of URL-encoding the slash.
While the frontend uses encodeURIComponent as a workaround, this fix
ensures the routes work correctly with both encoded and unencoded
paths, improving compatibility with external API consumers.
Closes Comfy-Org#10151
Member
Test Evidence CheckIf this PR changes user-facing behavior, visual proof (screen recording or screenshot) is required. PRs without applicable visual documentation may not be reviewed until provided. You can add it by:
|
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.
Summary
{file}to{file:.*}in all/userdata/routes to allow paths containing slashes (e.g.workflows/my-workflow.json){file}parameter only matches a single path segment in aiohttp, causing 404 errors when requesting files in subdirectories without URL-encoding the slashencodeURIComponentas a workaround, this fix ensures routes work correctly with both encoded and unencoded pathsProblem
Requests to
/userdata/workflows/filename.jsonreturn 404 because aiohttp's{file}route parameter only captures a single path segment (workflows), not the full path (workflows/filename.json).The existing
parse.unquote()workaround (from PR #4801) only helps when the frontend URL-encodes the slash as%2F. External API consumers and some frontend code paths that construct URLs with literal slashes are affected.Changes
app/user_manager.py— 4 route definitions updated:/userdata/{file}/userdata/{file:.*}/userdata/{file}/userdata/{file:.*}/userdata/{file}/userdata/{file:.*}/userdata/{file}/move/{dest}/userdata/{file:.*}/move/{dest:.*}Test plan
GET /userdata/workflows/test.jsonreturns 200 (was 404)GET /userdata/workflows%2Ftest.jsonstill works (backward compatible)Closes #10151