Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ def serialize(
cls.serialize(
{
"exc_cls_name": var.__class__.__name__,
"args": [var.args],
"args": list(var.args),
"kwargs": {},
},
strict=strict,
Expand Down
21 changes: 21 additions & 0 deletions airflow-core/tests/unit/serialization/test_serialized_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,27 @@ def test_roundtrip_exceptions():
assert deser.reschedule_date == some_date


@pytest.mark.parametrize(
"exc",
[
KeyError("boom"),
AttributeError("attr missing"),
KeyError("a", "b"),
KeyError(),
],
)
def test_roundtrip_builtin_exceptions(exc):
"""BaseSerialization should preserve ``args`` when round-tripping built-in exceptions.

Regression test for https://github.com/apache/airflow/issues/69743 where
a KeyError("boom") would deserialize with args == (("boom",),) instead of ("boom",).
"""
ser = BaseSerialization.serialize(exc)
deser = BaseSerialization.deserialize(ser)
assert isinstance(deser, type(exc))
assert deser.args == exc.args


@pytest.mark.parametrize(
"concurrency_parameter",
[
Expand Down