Repository navigation
Conversation
The provenance-bound test that refuses an unrenderable rawInput encodes a 5,000-deep payload with indent=2. On Python 3.12 that runs the pure-Python encoder down to RecursionError. A gen0 sweep landing in those innermost frames runs the finalizers of whatever cyclic garbage the worker carries; they overflow, pytest's unraisable hook overflows with them, and the test fails with "ExceptionGroup: multiple unraisable exception warnings". It did so on three unrelated PRs on 2026-10-24. Use the shared cyclic_gc_quiesced fixture, the remedy testing-conventions.md prescribes for a test that drives code to RecursionError on purpose. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Closing as a duplicate of #23330, which is assigned to @CrysisDeu. I found it only after opening this. The fix, the reproduction and the new occurrences are handed over in a comment there. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem / Motivation
Goal: the test that refuses an unrenderable
rawInputpasses or fails on the code it tests, not on whether a garbage-collection sweep lands while it sits at the recursion limit.test/test_tool_call_classification_provenance_bound.py::TestTheProvenanceCachesShareOneBound::test_a_payload_the_encoder_could_not_render_is_refused_not_retained_unmeasuredfailed on three unrelated PRs within an hour on 2026-10-24 (#19440, #23332, #15543), each time inBackend Tests (3.12, 5):The test encodes a 5,000-deep payload with
indent=2. On Python 3.12 that is the pure-Python encoder, which recurses toRecursionErroron purpose. A gen0 sweep that lands in those innermost frames runs the finalizers of whatever cyclic garbage the worker is carrying. They overflow, so does pytest's hook, and the test fails although every assertion held.Why it matters
A red Backend Tests shard on a PR that does not touch ACP costs a rerun, and a fork author cannot rerun upstream jobs, so the PR waits on a maintainer. File sharding is stable, so this test always runs on shard 5, and every PR whose run lands it next to such garbage is exposed.
Not a goal
_dumps_degradeddetects an unrenderable payload, or the depth the test uses.What changed (motivation → approach → change)
ExceptionGroupon unrelated PRs.RecursionErrorwith the cyclic collector on, whichdocs/system-specs/common/testing-conventions.mdnames as a flake class: "A test that drives code toRecursionErroron purpose must hold the cyclic collector off for the walk."test/test_tool_call_classification_provenance_bound.pyonly: the test uses the sharedstray_line_helpers.cyclic_gc_quiescedfixture (onegc.collect()at depth zero, the collector off for the test, then re-enabled and collected again), the remedy that section gives and the fixturetest_acp_frame_record.pyalready uses. Reference counting still frees the walk's own objects; only cycles wait for teardown.Backwards compatibility
Compatible: test-only; no product code changes.
Removes nothing: the test makes the same assertions.
Tests
gc.set_threshold(1, 1, 1)for the call and plants one logging-finalizer cycle after every sweep, the shape of a pending Task an earlier test leaked. On main the test fails 3 of 3 runs with the CIExceptionGroup. With this change it passes 3 of 3, and no finalizer runs during the call. Without the plugin, main passes. The plugin is in Flaky: test_a_payload_the_encoder_could_not_render_is_refused_not_retained_unmeasured fails with unraisable RecursionError on Python 3.12 #23770.test/test_tool_call_classification_provenance_bound.py: 26 passed on Python 3.12.13; withtest/test_tool_call_classification.py, 70 passed on 3.13.5. The same harness does not fail main on 3.13.5 here.test/test_flake_pattern_ratchet.py: 60 passed. black, isort, flake8,check_comment_history,check_brand_nameandcheck_subprocess_encodingpass on the diff.Proof: not provable -- test-only change
Manual verification
N/A — test-only change; the reproduction above is the check.
Related Issues
Fixes #23770
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
🤖 Generated with Claude Code