Skip to content

Fix BaseSerialization double-wrapping args for builtin exceptions#69752

Open
bujjibabukatta wants to merge 1 commit into
apache:mainfrom
bujjibabukatta:fix/#69743
Open

Fix BaseSerialization double-wrapping args for builtin exceptions#69752
bujjibabukatta wants to merge 1 commit into
apache:mainfrom
bujjibabukatta:fix/#69743

Conversation

@bujjibabukatta

Copy link
Copy Markdown
Contributor

Ran into this from #69743BaseSerialization was mangling args for
built-in exceptions like KeyError on the round trip.

Turns out the exception-serialization branch for KeyError/AttributeError
was storing args as [var.args]. Since var.args is already a tuple
(e.g. ("boom",)), that wraps it in an extra layer. When deserializing,
exc_cls(*args) unpacks that as a single positional arg — so you get
KeyError(("boom",)) instead of KeyError("boom"), and .args comes back
as (("boom",),) instead of ("boom",).

Fix is a one-liner: store list(var.args) instead of [var.args] so it
stays flat.

Added a parametrized test covering single-arg, multi-arg, and no-arg
KeyError/AttributeError round-trips so this doesn't regress.

closes: #69743

@nailo2c

nailo2c commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Hi @bujjibabukatta, thanks for the contribution! I'm a bit concerned this might introduce a regression. Could you please double-check to ensure this change won't break existing behavior? Thanks!

@bujjibabukatta

Copy link
Copy Markdown
Contributor Author

Hi @nailo2c
Thanks for the review!
I actually went and traced through it before replying instead of just saying "should be fine." Deserialize is untouched, only serialize changed, so anything already sitting in the db from old runs deserializes exactly the same as before, no breakage there. Also checked where this actually gets used (trigger failure handling, xcom etc) and nothing depends on the old broken args shape. The only real difference is the error message itself is correct now instead of showing up wrapped in a weird extra tuple, which was the whole bug. Threw in a newsfragment too so it shows up in release notes. Happy to add more tests if you've got a specific case in mind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BaseSerialization adds an extra tuple layer to built-in exception args

2 participants