diff --git a/app/auth.py b/app/auth.py index a488691..842bf12 100644 --- a/app/auth.py +++ b/app/auth.py @@ -20,6 +20,15 @@ def require_auth(func): if valid_brearer_token(): return func(*args, **kwargs) else: - return Response("Unauthorized", 401) + error_message = ( + "\nAuthentication with Cursor-Azure-GPT-5 service failed.\n\n" + "These value of:\n" + "\tCursor Settings > Models > API Keys > OpenAI API Key\n\n" + "Must match the value of:\n" + "\tSERVICE_API_KEY in your .env file\n\n" + "Ensure the values match exactly, and try again.\n" + "If modifying the .env file, restart the service for the changes to apply." + ) + return Response(error_message, 400) return wrapper diff --git a/app/azure/adapter.py b/app/azure/adapter.py index 902a9d8..64ea65b 100644 --- a/app/azure/adapter.py +++ b/app/azure/adapter.py @@ -86,6 +86,7 @@ class AzureAdapter: "endpoint": re.sub( r"(//.)(.*?)(.\.)", "\\1***\\3", request_kwargs.get("url") ), + "azure_status_code": resp.status_code, "azure_response": resp_content, "request_body": body, } @@ -102,5 +103,5 @@ class AzureAdapter: console.print(error_message) return Response( error_message, - status=resp.status_code, + status=resp.status_code if resp.status_code != 401 else 400, ) diff --git a/tests/test_functional.py b/tests/test_functional.py index 0de755e..261ac60 100644 --- a/tests/test_functional.py +++ b/tests/test_functional.py @@ -17,9 +17,9 @@ class TestConfig: class TestModels: """Models.""" - def test_models_endpoint_returns_200(self, testapp): - """Ensure /models endpoint returns HTTP 200.""" - testapp.get("/models", status=401) + def test_models_endpoint_returns_400(self, testapp): + """Ensure /models endpoint returns HTTP 400.""" + testapp.get("/models", status=400) def test_health_endpoint_returns_200(self, testapp): """Ensure /health endpoint returns HTTP 200."""