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.
This commit is contained in:
GareArc 2026-05-07 01:08:59 -07:00
parent f2ec17be9b
commit 4bc1046f14
No known key found for this signature in database

View File

@ -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()