From fbd9b800d38907ff6aceaf8ef8483f7b7709a307 Mon Sep 17 00:00:00 2001 From: Greyson Lalonde Date: Thu, 12 Mar 2026 22:34:16 -0400 Subject: [PATCH] fix: add error handling to update_user_data --- .../src/crewai/events/listeners/tracing/utils.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/crewai/src/crewai/events/listeners/tracing/utils.py b/lib/crewai/src/crewai/events/listeners/tracing/utils.py index b5571b426..9382f137c 100644 --- a/lib/crewai/src/crewai/events/listeners/tracing/utils.py +++ b/lib/crewai/src/crewai/events/listeners/tracing/utils.py @@ -158,11 +158,14 @@ def update_user_data(updates: dict[str, Any]) -> None: Args: updates: Key-value pairs to merge into the existing user data. """ - with store_lock(_user_data_lock_name()): - data = _load_user_data() - data.update(updates) - p = _user_data_file() - p.write_text(json.dumps(data, indent=2)) + try: + with store_lock(_user_data_lock_name()): + data = _load_user_data() + data.update(updates) + p = _user_data_file() + p.write_text(json.dumps(data, indent=2)) + except (OSError, PermissionError) as e: + logger.warning(f"Failed to update user data: {e}") def has_user_declined_tracing() -> bool: