Skip to content

Commit 2dff2e5

Browse files
devin-ai-integration[bot]bot_apk
andcommitted
fix: use 'is not None' checks in __str__ to handle empty string message
Address Copilot review: use explicit 'is not None' checks instead of truthiness so that message='' is respected and does not fall back to internal_message. Add test for this edge case. Co-Authored-By: bot_apk <apk@cognition.ai>
1 parent e19060c commit 2dff2e5

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

airbyte_cdk/utils/traced_exception.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,9 @@ def __init__(
5151

5252
def __str__(self) -> str:
5353
"""Return the user-facing message, falling back to internal_message."""
54-
55-
if self.message:
54+
if self.message is not None:
5655
return self.message
57-
elif self.internal_message:
56+
if self.internal_message is not None:
5857
return self.internal_message
5958
return ""
6059

unit_tests/utils/test_traced_exception.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,14 @@ def test_stack_trace_uses_str_representation(self) -> None:
246246
airbyte_message = exc.as_airbyte_message()
247247
assert "User sees this." in airbyte_message.trace.error.stack_trace
248248

249+
def test_str_with_empty_message_does_not_fall_back_to_internal_message(self) -> None:
250+
"""Explicit empty message should be respected and not replaced by internal_message."""
251+
exc = AirbyteTracedException(
252+
internal_message="an internal error that should not be shown to the user",
253+
message="",
254+
)
255+
assert str(exc) == ""
256+
249257
def test_internal_message_preserved_in_trace_error(self) -> None:
250258
"""Verify internal_message is still available in the trace error for debugging."""
251259
exc = AirbyteTracedException(

0 commit comments

Comments
 (0)