mirror of
https://github.com/langgenius/dify.git
synced 2026-05-10 05:56:31 +08:00
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:
parent
f2ec17be9b
commit
4bc1046f14
@ -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()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user