Extra safe error adapters (#556)

Catching and logging all unexpected errors that occur in the error
adapters _**just in case**_
This commit is contained in:
Eric Gustin 2025-09-10 14:51:18 -07:00 committed by GitHub
parent 9c1b2b9275
commit f50e05aa9b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 15 additions and 6 deletions

View file

@ -75,9 +75,9 @@ class GoogleErrorAdapter:
}
# Try to extract request details if available
if hasattr(error, "uri"):
if hasattr(error, "uri") and error.uri:
extra["endpoint"] = self._sanitize_uri(error.uri)
if hasattr(error, "method_"):
if hasattr(error, "method_") and error.method_:
extra["http_method"] = error.method_.upper()
# Special case for rate limiting

View file

@ -1,5 +1,6 @@
import functools
import inspect
import logging
from typing import Any, Callable, TypeVar
from arcade_tdk.auth import ToolAuthorization
@ -14,6 +15,8 @@ from arcade_tdk.utils import snake_to_pascal_case
T = TypeVar("T")
logger = logging.getLogger(__name__)
def _build_adapter_chain(
adapters: list[ErrorAdapter] | None, auth_provider: ToolAuthorization | None
@ -81,7 +84,13 @@ def _raise_as_arcade_error(
ToolRuntimeError or some subclass thereof
"""
for adapter in adapter_chain:
mapped = adapter.from_exception(exception)
try:
mapped = adapter.from_exception(exception)
except Exception as e:
logger.warning(
f"Failed to map exception to Arcade Error with adapter {adapter.slug}: {e}"
)
continue
if isinstance(mapped, ToolRuntimeError):
raise mapped from exception

View file

@ -1,6 +1,6 @@
[project]
name = "arcade-tdk"
version = "2.3.0"
version = "2.3.1"
description = "Arcade TDK - Toolkit Development Kit for building Arcade tools"
readme = "README.md"
license = {text = "MIT"}

View file

@ -1,6 +1,6 @@
[project]
name = "arcade-ai"
version = "2.2.0"
version = "2.2.1"
description = "Arcade.dev - Tool Calling platform for Agents"
readme = "README.md"
license = {file = "LICENSE"}
@ -42,7 +42,7 @@ all = [
# serve
"arcade-serve>=2.1.0,<3.0.0",
# tdk
"arcade-tdk>=2.3.0,<3.0.0",
"arcade-tdk>=2.3.1,<3.0.0",
]
# Evals also depends on arcade-core and openai, but they are already required deps
evals = [