From 14f023cd00c60da03bf2597904eba7f8338797f4 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Thu, 16 Jul 2026 06:49:11 -0700 Subject: [PATCH] fix(api_server): run platform event verifiers off-loop and fail closed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The platform callback verifier can do blocking network I/O (e.g. the google-chat adapter fetches Google signing certs on a cache miss), which would stall the event loop if called inline. Run sync verifiers via asyncio.to_thread (await coroutine verifiers directly), and treat a crashing verifier as a 401 rather than a 500 through the dispatch path — a broken verifier must never admit an event. --- gateway/platforms/api_server.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/gateway/platforms/api_server.py b/gateway/platforms/api_server.py index 97add25763ba..bfe3d3558648 100644 --- a/gateway/platforms/api_server.py +++ b/gateway/platforms/api_server.py @@ -1328,7 +1328,20 @@ class APIServerAdapter(BasePlatformAdapter): status=503, ) - ok, code = verifier(request.headers.get("Authorization", "")) + auth_header = request.headers.get("Authorization", "") + try: + if asyncio.iscoroutinefunction(verifier): + ok, code = await verifier(auth_header) + else: + # Platform verifiers may do blocking network I/O (e.g. Google + # signing-cert fetches) — keep that off the event loop. + ok, code = await asyncio.to_thread(verifier, auth_header) + except Exception: + # Fail closed: a crashing verifier must never admit the event. + logger.exception( + "Platform HTTP event verifier failed for %s", platform_name + ) + ok, code = False, "platform_event_verifier_error" if not ok: return web.json_response( _openai_error(