fix: UploadFile ForwardRef error + WebSocket 403 CSRF block

1. plugin_error_handler.py: Remove return_annotation from copied signature
   to prevent FastAPI ForwardRef('UploadFile') resolution failure on routes
   with file upload endpoints (dms, calendar, mail, kommunikation, ai_assistant)

2. middleware.py: Skip CSRF check for WebSocket upgrade requests
   WebSocket connections use GET with upgrade header — should not be
   blocked by CSRF middleware
This commit is contained in:
Agent Zero
2026-07-27 01:08:51 +02:00
parent 1c01bbccb7
commit 09cd1a5fe2
2 changed files with 12 additions and 4 deletions
+4
View File
@@ -69,6 +69,10 @@ class CSRFMiddleware(BaseHTTPMiddleware):
UNSAFE_METHODS = {"POST", "PATCH", "PUT", "DELETE"}
async def dispatch(self, request: Request, call_next):
# Skip WebSocket upgrade requests — they use GET and are handled separately
if request.headers.get("upgrade", "").lower() == "websocket":
return await call_next(request)
if request.method in self.UNSAFE_METHODS:
# 1. Origin header check
origin = request.headers.get("origin")