From 495d01b09bfaa618c02431ca7ef84c4c417086ec Mon Sep 17 00:00:00 2001 From: Otto Date: Mon, 9 Feb 2026 07:52:45 +0000 Subject: [PATCH] fix: use getattr for pyright type checking on dynamic error attributes Fixes pyright errors: - Cannot access attribute 'code' for class 'Exception' - Cannot access attribute 'param' for class 'Exception' Using getattr() instead of direct attribute access satisfies pyright's type checker while maintaining the same runtime behavior. --- autogpt_platform/backend/backend/api/features/chat/service.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autogpt_platform/backend/backend/api/features/chat/service.py b/autogpt_platform/backend/backend/api/features/chat/service.py index 6d68c24dd0..2a93319f84 100644 --- a/autogpt_platform/backend/backend/api/features/chat/service.py +++ b/autogpt_platform/backend/backend/api/features/chat/service.py @@ -1822,9 +1822,9 @@ def _extract_api_error_details(error: Exception) -> dict[str, Any]: } if hasattr(error, "code"): - details["code"] = error.code + details["code"] = getattr(error, "code", None) if hasattr(error, "param"): - details["param"] = error.param + details["param"] = getattr(error, "param", None) if isinstance(error, APIStatusError): details["status_code"] = error.status_code