Skip to content

Conversation

@wangzlei
Copy link
Contributor

@wangzlei wangzlei commented Oct 1, 2025

Issue #, if available:
When segment metadata contains objects having circular reference, the segment serialization will get RecursionError exception. Then the log.exception in conversion.py will print infinite logs util hitting a new RecursionError exception, causes log flood in user application logs.

Description of changes:
Using pprint instead of normal logging. pprint can handle cycles because it tracks objects it has already visited and, when it detects a recursive reference, it prints a placeholder like <Recursion on ...> instead of recursing, preventing log flood. The output looks like

Caught exception: dict contains cycle
  attribute: payload ->
{'name': 'loop',
 'self': <Recursion on dict with id=4414423360>}
  attribute: _recorded ->
True
  attribute: _cause_id ->
'6dd1416f68a1c043'
  gc.collect() returned: 51732
----------------------------------------
Caught exception: dict contains cycle
  attribute: payload ->
{'name': 'loop',
 'self': <Recursion on dict with id=4420684992>}
  attribute: _recorded ->
True
  attribute: _cause_id ->
'ac93f095f48beedf'
  gc.collect() returned: 6

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@wangzlei wangzlei requested a review from a team as a code owner October 1, 2025 19:04
Copy link
Contributor

@vastin vastin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wangzlei wangzlei merged commit b893c9b into aws:master Oct 10, 2025
12 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants