fix(describe): guard pr_description config reads against missing keys (#2238)#2478
Merged
Merged
Conversation
A custom .pr_agent.toml that overrides the [pr_description] section drops the section defaults, because custom_merge_loader replaces sections instead of merging fields. The unguarded reads of enable_large_pr_handling, async_ai_calls and max_ai_calls then raised 'DynaBox object has no attribute ...', which retry_with_fallback_models swallowed as a failed prediction until every model failed and /describe crashed. Read these keys via .get(..., default) so the documented defaults apply when a custom config omits them. #2238
Contributor
PR Summary by QodoFix /describe crash when pr_description config keys are missing Description
Diagram
High-Level Assessment
Files changed (3)
|
Contributor
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.
What
Fixes the
'DynaBox' object has no attribute 'enable_large_pr_handling'crash on/describe.Closes #2238
Why it still happens after #2234
#2234 restored
enable_large_pr_handling/max_ai_calls/async_ai_callsas defaults inconfiguration.toml, but the reads were left as direct attribute access. The catch iscustom_merge_loaderreplaces a whole section instead of merging fields (it documents this in its own docstring). So any user whose custom.pr_agent.tomlhas a[pr_description]section that omits these keys loses the defaults at runtime, and the unguarded read throws.retry_with_fallback_modelsswallows it as a failed prediction and keeps trying models until the run fails - which is exactly what a v0.34 user with an older config reported.The fix
Read the three keys via
.get(..., default)at the call sites, so the documented defaults apply even when a custom config replaces the section:pr_agent/tools/pr_description.py:211-enable_large_pr_handling(defaultTrue)pr_agent/tools/pr_description.py:247-async_ai_calls(defaultTrue)pr_agent/algo/pr_processing.py:262-max_ai_calls(default4)Defaults match
configuration.toml.Test
Added
test_pr_description_reads_fall_back_when_keys_missing, which reproduces the overridden section with aDynaBoxmissing the keys, asserts bare attribute access raises the original error, and verifies the guarded reads fall back to the defaults.