From 4606a7bc39849b8f45d4557ff87455260cf669ab Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Mon, 2 Mar 2026 08:26:06 -0600 Subject: [PATCH] update instructions to prevent exposing exception info --- .github/copilot-instructions.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index f053abe3f..0af9c249f 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -324,6 +324,12 @@ try: value = await sensor.read() except Exception: # ❌ Too broad logger.error("Failed") + +# Returning exceptions in JSON responses +except ValueError as e: + return JSONResponse( + content={"success": False, "message": str(e)}, + ) ``` ### ✅ Use These Instead @@ -353,6 +359,16 @@ try: value = await sensor.read() except SensorException as err: # ✅ Specific logger.exception("Failed to read sensor") + +# Safe error responses +except ValueError: + logger.exception("Invalid parameters for API request") + return JSONResponse( + content={ + "success": False, + "message": "Invalid request parameters", + }, + ) ``` ## Project-Specific Conventions