From 4bc1046f14016600c5a9ea4c6d226d40dd6a7ce9 Mon Sep 17 00:00:00 2001 From: GareArc Date: Thu, 7 May 2026 01:08:59 -0700 Subject: [PATCH] fix(openapi): tighten /run handler error path + drop cargo-cult call - Drop except ValueError: raise. Inherited from per-mode controllers without examining purpose; today it converts helper-internal ValueErrors into uncaptured 500s with no body or log. Falling through to except Exception: gives them a logged trace and a structured InternalServerError. - Drop redundant AppMode.value_of(app_model.mode). App.mode is Mapped[AppMode] with an EnumText adapter that returns the enum directly; value_of was a no-op iteration. - Comment the explicit re-raise block to spell out why ordering matters before the catch-all. --- api/controllers/openapi/app_run.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/api/controllers/openapi/app_run.py b/api/controllers/openapi/app_run.py index 769b6f0588..4426024244 100644 --- a/api/controllers/openapi/app_run.py +++ b/api/controllers/openapi/app_run.py @@ -220,20 +220,19 @@ class AppRunApi(Resource): except ValidationError as exc: raise UnprocessableEntity(exc.json()) - mode = AppMode.value_of(app_model.mode) + mode = app_model.mode handler = _DISPATCH.get(mode) if handler is None: raise UnprocessableEntity("mode_not_runnable") streaming = payload.response_mode == "streaming" + # Preserve specific HTTPException codes that the catch-all would otherwise mask. try: stream_obj, blocking_body = handler(app_model, caller, payload, streaming) except UnprocessableEntity: raise except (NotChatAppError, NotWorkflowAppError): raise - except ValueError: - raise except Exception: logger.exception("internal server error.") raise InternalServerError()