Repository navigation
Conversation
…suggestions is_successful was only ever assigned inside the `if suggestions_to_publish:` branch, but referenced unconditionally afterward. When supports_suggestions_artifact is True and artifact_suggestions is empty while code_suggestions is non-empty, suggestions_to_publish resolves to an empty list, so is_successful is never assigned before the `if code_suggestions and not is_successful:` check, raising a NameError. Found via CodeQL alert py/uninitialized-local-variable on Agrematch/pr-agent. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
ira-at-work
deleted the
fix/code-suggestions-uninitialized-is-successful
branch
October 21, 2026 11:35
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.
Summary
Fixes a real
NameErrorfound by GitHub Code Scanning (CodeQL rulepy/uninitialized-local-variable) onmain.In
PRCodeSuggestions.push_inline_code_suggestions,is_successfulis only assigned inside theif suggestions_to_publish:branch, but is referenced unconditionally later:suggestions_to_publish = artifact_suggestions if supports_suggestions_artifact else code_suggestions. Whensupports_suggestions_artifactisTrueandartifact_suggestionsis empty whilecode_suggestionsis non-empty,suggestions_to_publishis falsy, the assignment branch never runs, and the later reference raisesNameErrorat runtime.Changes
Initialize
is_successful = Falsealongside the other state variables at the top of the method, matching the pattern already used forartifact_batch_published.Testing
ruff check pr_agent/tools/pr_code_suggestions.py- cleanpytest tests/unittest/test_pr_code_suggestions_lifecycle.py tests/unittest/test_git_provider_code_suggestions.py tests/unittest/test_gitlab_batch_publish_suggestions.py- all passingpytest tests/unittest/test_pr_code_suggestions_core.py- 293/313 passing; the 20 failures are pre-existing and unrelated (sandbox network blocks a tiktoken encoding download over HTTPS,SSLCertVerificationError), none touchpush_inline_code_suggestionsoris_successfulContext
Part of a sweep triaging the 187 open CodeQL alerts on this repo's
main, per Ira's instruction to resolve what's fixable in PRs and dismiss false positives/irrelevant findings for the rest.🤖 Generated with Claude Code