From e914b6af39a3d9ae1a77fb36b3afc6403759766b Mon Sep 17 00:00:00 2001 From: Quigley Malcolm Date: Fri, 31 Mar 2023 09:19:16 -0700 Subject: [PATCH] Log warning when event serialization fails in `msg_to_dict` This commit updates the `msg_to_dict` exception handling path to fire a warning level event instead of raising an exception. Truthfully, we're not sure if this exception handling path is even possible to hit. That's because we recently switched from betterproto to google's protobuf. However, exception path is the subject of [CT-2264](https://github.com/dbt-labs/dbt-core/issues/7113). Though we don't think it's actually possible to hit it anymore, we still want to handle the case if it is. --- core/dbt/events/functions.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/dbt/events/functions.py b/core/dbt/events/functions.py index 39a85b57de8..21141e71249 100644 --- a/core/dbt/events/functions.py +++ b/core/dbt/events/functions.py @@ -2,7 +2,7 @@ from dbt.events.base_types import BaseEvent, EventLevel, EventMsg from dbt.events.eventmgr import EventManager, LoggerConfig, LineFormat, NoFilter from dbt.events.helpers import env_secrets, scrub_secrets -from dbt.events.types import Formatting +from dbt.events.types import Formatting, Note from dbt.flags import get_flags, ENABLE_LEGACY_LOGGER from dbt.logger import GLOBAL_LOGGER, make_log_dir_if_missing from functools import partial @@ -219,7 +219,9 @@ def msg_to_dict(msg: EventMsg) -> dict: ) except Exception as exc: event_type = type(msg).__name__ - raise Exception(f"type {event_type} is not serializable. {str(exc)}") + fire_event( + Note(msg=f"type {event_type} is not serializable. {str(exc)}"), level=EventLevel.WARN + ) # We don't want an empty NodeInfo in output if ( "data" in msg_dict