From f6a49ec19d0cf83ffbec214163163c0262c8976c Mon Sep 17 00:00:00 2001 From: Diwank Singh Tomer Date: Thu, 19 Dec 2024 15:17:32 +0530 Subject: [PATCH] Fix code scanning alert no. 4: Information exposure through an exception Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- agents-api/agents_api/routers/healthz/check_health.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/agents-api/agents_api/routers/healthz/check_health.py b/agents-api/agents_api/routers/healthz/check_health.py index 9336609b8..8e96c2b1e 100644 --- a/agents-api/agents_api/routers/healthz/check_health.py +++ b/agents-api/agents_api/routers/healthz/check_health.py @@ -3,7 +3,7 @@ from ...autogen.openapi_model import Agent, ListResponse from ...models.agent.list_agents import list_agents as list_agents_query from .router import router - +import logging @router.get("/healthz", tags=["healthz"]) async def check_health() -> dict: @@ -13,6 +13,7 @@ async def check_health() -> dict: developer_id=UUID("00000000-0000-0000-0000-000000000000"), ) except Exception as e: - return {"status": "error", "message": str(e)} + logging.error("An error occurred while checking health: %s", str(e)) + return {"status": "error", "message": "An internal error has occurred."} return {"status": "ok"}