From 80adc426140148ee117f7c9c829156e56548d23b Mon Sep 17 00:00:00 2001 From: Peter Double Date: Tue, 1 Apr 2025 22:31:32 -0400 Subject: [PATCH] fastapi_paths to tuple and simplified startswith check --- llama_stack/distribution/server/server.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/llama_stack/distribution/server/server.py b/llama_stack/distribution/server/server.py index ad1bcfa78..3d3c0df2e 100644 --- a/llama_stack/distribution/server/server.py +++ b/llama_stack/distribution/server/server.py @@ -230,13 +230,13 @@ class TracingMiddleware: self.app = app self.impls = impls # FastAPI built-in paths that should bypass custom routing - self.fastapi_paths = [ + self.fastapi_paths = ( "/docs", "/redoc", "/openapi.json", "/favicon.ico", "/static" - ] + ) async def __call__(self, scope, receive, send): if scope.get("type") == "lifespan": @@ -245,7 +245,7 @@ class TracingMiddleware: path = scope.get("path", "") # Check if the path is a FastAPI built-in path - if any(path.startswith(fastapi_path) for fastapi_path in self.fastapi_paths): + if path.startswith(self.fastapi_paths): # Pass through to FastAPI's built-in handlers logger.debug(f"Bypassing custom routing for FastAPI built-in path: {path}") return await self.app(scope, receive, send)