-
Notifications
You must be signed in to change notification settings - Fork 16.4k
Fix serde recursion limit test by using correct MAX_RECURSION_DEPTH #61182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| def test_serde_serialize_recursion_limit(self): | ||
| depth = MAX_RECURSION_DEPTH | ||
| with pytest.raises(RecursionError, match="maximum recursion depth reached for serialization"): | ||
| serialize(object(), depth=depth) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you fixing a test or adding a new one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am fixing a test (readding a previously removed flaky test with a fix)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amoghrajesh It’s more like a fix, I think, because someone found this test was flaky and just deleted it.
FYI #51737
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, yes it shouldnt have been deleted!
| def test_serde_serialize_recursion_limit(self): | ||
| depth = MAX_RECURSION_DEPTH | ||
| with pytest.raises(RecursionError, match="maximum recursion depth reached for serialization"): | ||
| serialize(object(), depth=depth) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, yes it shouldnt have been deleted!
This PR fixes a flaky unit test
test_serde_serialize_recursion_limitintask-sdk.The test was previously using
sys.getrecursionlimit() - 1to simulate the recursion depth. However, this system limit (often 1000) does not match the internalMAX_RECURSION_DEPTHconstant (which is 10) used in theserializefunction.Because of this mismatch, the
depthcheck inserializepassed (since 999 != 10), causing the function to attempt to serialize the emptyobject(), resulting in aTypeErrorinstead of the expectedRecursionError.Verification
Ran the test locally with
pytestand it passed:Changes:
MAX_RECURSION_DEPTHfromairflow.sdk.serde.serde.depthparameter to correctly trigger theRecursionError.closes: #51915