fix: allow multi-segment paths in userdata API routes

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 #10151
This commit is contained in:
Peuqui 2026-02-14 13:56:34 +01:00
parent dc9822b7df
commit 65c24fe8b3

View File

@ -330,7 +330,7 @@ class UserManager():
return path
@routes.get("/userdata/{file}")
@routes.get("/userdata/{file:.*}")
async def getuserdata(request):
path = get_user_data_path(request, check_exists=True)
if not isinstance(path, str):
@ -338,7 +338,7 @@ class UserManager():
return web.FileResponse(path)
@routes.post("/userdata/{file}")
@routes.post("/userdata/{file:.*}")
async def post_userdata(request):
"""
Upload or update a user data file.
@ -394,7 +394,7 @@ class UserManager():
return web.json_response(resp)
@routes.delete("/userdata/{file}")
@routes.delete("/userdata/{file:.*}")
async def delete_userdata(request):
path = get_user_data_path(request, check_exists=True)
if not isinstance(path, str):
@ -404,7 +404,7 @@ class UserManager():
return web.Response(status=204)
@routes.post("/userdata/{file}/move/{dest}")
@routes.post("/userdata/{file:.*}/move/{dest:.*}")
async def move_userdata(request):
"""
Move or rename a user data file.