From 23f8dbb6e788c611e168661287def462edf1ada3 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Wed, 15 May 2024 07:45:57 -0400 Subject: [PATCH] Don't use `include_url` with Pydantic's V1 `ValidationError` --- logfire/_internal/main.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/logfire/_internal/main.py b/logfire/_internal/main.py index 959b07437..89d965251 100644 --- a/logfire/_internal/main.py +++ b/logfire/_internal/main.py @@ -1375,7 +1375,11 @@ def _record_exception( attributes = {**(attributes or {})} if ValidationError is not None and isinstance(exception, ValidationError): # insert a more detailed breakdown of pydantic errors - err_json = exception.json(include_url=False) + try: + err_json = exception.json(include_url=False) + except TypeError: # pragma: no cover + # pydantic v1 + err_json = exception.json() span.set_attribute(ATTRIBUTES_VALIDATION_ERROR_KEY, err_json) attributes[ATTRIBUTES_VALIDATION_ERROR_KEY] = err_json