fix: remove wrap_plugin_route — it broke ForwardRef resolution for body params

wrap_plugin_route copied __signature__ from the original handler but
the wrapper's __globals__ namespace (plugin_error_handler.py) did not
contain the Pydantic models (ConversationCreate, MessageCreate, etc.).
FastAPI could not resolve ForwardRef('ConversationCreate') → 422 on
all POST routes with body parameters.

Removing the wrapper entirely fixes this. Plugin error isolation can
be re-added later using a different approach (middleware or exception handler).
This commit is contained in:
Agent Zero
2026-07-27 02:51:20 +02:00
parent 24fb384cf9
commit b24ac6883f
+2 -7
View File
@@ -435,17 +435,12 @@ def create_app() -> FastAPI:
try:
router_module = importlib.import_module(route_def.module)
router = getattr(router_module, route_def.router_attr)
# Wrap each HTTP route handler with plugin error isolation
# and add active-plugin check per-route (not router-level)
# so WebSocket routes are NOT affected.
# Skip WebSocket routes — no wrapping, no plugin check
from starlette.routing import WebSocketRoute
from fastapi import APIRouter as _AR
plugin_dep = Depends(require_active_plugin(plugin_name))
for route in router.routes:
if isinstance(route, WebSocketRoute):
continue # WebSocket: no wrap, no plugin check
if hasattr(route, 'endpoint'):
route.endpoint = wrap_plugin_route(route.endpoint)
continue
# Add require_active_plugin to each HTTP route's dependencies
if not hasattr(route, 'dependencies'):
route.dependencies = []