Skip to content

fix: allow multi-segment paths in userdata API routes#12468

Open
Peuqui wants to merge 1 commit intoComfy-Org:masterfrom
Peuqui:fix/userdata-route-multi-segment-paths
Open

fix: allow multi-segment paths in userdata API routes#12468
Peuqui wants to merge 1 commit intoComfy-Org:masterfrom
Peuqui:fix/userdata-route-multi-segment-paths

Conversation

@Peuqui
Copy link

@Peuqui Peuqui commented Feb 14, 2026

Summary

  • Change aiohttp route parameters from {file} to {file:.*} in all /userdata/ routes to allow paths containing slashes (e.g. workflows/my-workflow.json)
  • The {file} parameter only matches a single path segment in aiohttp, causing 404 errors when requesting files in subdirectories without URL-encoding the slash
  • While the frontend uses encodeURIComponent as a workaround, this fix ensures routes work correctly with both encoded and unencoded paths

Problem

Requests to /userdata/workflows/filename.json return 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:

Route Before After
GET /userdata/{file} /userdata/{file:.*}
POST /userdata/{file} /userdata/{file:.*}
DELETE /userdata/{file} /userdata/{file:.*}
POST (move) /userdata/{file}/move/{dest} /userdata/{file:.*}/move/{dest:.*}

Test plan

  • Verify GET /userdata/workflows/test.json returns 200 (was 404)
  • Verify GET /userdata/workflows%2Ftest.json still works (backward compatible)
  • Verify workflow sidebar loading works for files in subdirectories
  • Verify saving workflows to subdirectories works
  • Verify file move/rename still works

Closes #10151

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
@comfy-pr-bot
Copy link
Member

Test Evidence Check

⚠️ Warning: Visual Documentation Missing

If 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:

  • GitHub: Drag & drop media directly into the PR description
  • YouTube: Include a link to a short demo

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.

Make userdata subdirectories and files accessible to retrieve workflow

2 participants