From 0ffc5d7bacf7300cc2270b40d7185d2634a2fe27 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Fri, 13 Mar 2026 16:55:46 +0100 Subject: [PATCH] Fix legacy_expose_api error callable returning str instead of bytes The error inner function was used as a WSGI sub-application but returned a bare string. WSGI requires response bodies to be iterables of byte strings. With a2wsgi converting to ASGI, h11 rejects the str, causing a TypeError in starlette's BaseHTTPMiddleware. --- lib/galaxy/web/framework/decorators.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/galaxy/web/framework/decorators.py b/lib/galaxy/web/framework/decorators.py index 13b8d7dd70f..b76fd717d4d 100644 --- a/lib/galaxy/web/framework/decorators.py +++ b/lib/galaxy/web/framework/decorators.py @@ -20,6 +20,7 @@ from galaxy.exceptions.utils import ( ) from galaxy.util import ( parse_non_hex_float, + smart_str, unicodify, ) from galaxy.util.json import safe_dumps @@ -154,7 +155,7 @@ def legacy_expose_api(func, to_json=True, user_required=True): def decorator(self, trans, *args, **kwargs): def error(environ, start_response): start_response(error_status, [("Content-type", "text/plain")]) - return error_message + return [smart_str(error_message)] error_status = "403 Forbidden" if trans.error_message: