Skip to content

Conversation

@Eason09053360
Copy link

This PR fixes a flaky unit test test_serde_serialize_recursion_limit in task-sdk.

The test was previously using sys.getrecursionlimit() - 1 to simulate the recursion depth. However, this system limit (often 1000) does not match the internal MAX_RECURSION_DEPTH constant (which is 10) used in the serialize function.

Because of this mismatch, the depth check in serialize passed (since 999 != 10), causing the function to attempt to serialize the empty object(), resulting in a TypeError instead of the expected RecursionError.

Verification

Ran the test locally with pytest and it passed:

截圖 2026-01-29 凌晨3 17 53

Changes:

  • Imported MAX_RECURSION_DEPTH from airflow.sdk.serde.serde.
  • Updated the test to use this constant for the depth parameter to correctly trigger the RecursionError.

closes: #51915

Comment on lines +678 to +681
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)
Copy link
Contributor

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?

Copy link
Author

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)

Copy link
Contributor

@henry3260 henry3260 Jan 29, 2026

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

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.

Investigate CI failure of test_serde_serialize_recursion_limit

3 participants