diff --git a/.env b/.env index af1265e..6fa5ec4 100644 --- a/.env +++ b/.env @@ -3,4 +3,4 @@ # If you want to push to a local instance of explorer, then specify the app-api docker container name like: # http://:8000 to push to the local explorer instance. INVARIANT_API_URL=https://explorer.invariantlabs.ai -GUADRAILS_API_URL=https://explorer.invariantlabs.ai +GUADRAILS_API_URL=https://explorer.invariantlabs.ai \ No newline at end of file diff --git a/gateway/common/config_manager.py b/gateway/common/config_manager.py index ad85149..5978690 100644 --- a/gateway/common/config_manager.py +++ b/gateway/common/config_manager.py @@ -9,12 +9,15 @@ import fastapi from httpx import HTTPStatusError -def extract_policy_from_headers(request: fastapi.Request) -> Optional[str]: +def extract_policy_from_headers(request: Optional[fastapi.Request]) -> Optional[str]: """ Extracts the guardrailing policy from the request headers if present. Returns 'None' if no such header is present. """ + if request is None: + return None + policy = request.headers.get("Invariant-Guardrails") # undo unicode_escape if policy: