fix: add debug logging for programming exceptions caught by ANY_GIT_ERROR#4945
Open
ernestodeoliveira wants to merge 1 commit intoAider-AI:mainfrom
Open
Conversation
…RROR ANY_GIT_ERROR includes TypeError, ValueError, AttributeError, and AssertionError — exception types that indicate programming bugs, not git errors. When these are silently caught at 22+ call sites, real bugs become invisible to users and developers (issue Aider-AI#4932). This commit adds logger.debug() before every silent except ANY_GIT_ERROR block, so programming exceptions surface in debug logs without changing any user-visible behavior. Also fixes a redundant (TypeError,) + ANY_GIT_ERROR in repo.py:384 and get_head_commit: since TypeError and ValueError are already members of ANY_GIT_ERROR, the manual prepend was a no-op that indicated the tuple contents were not well-understood. No behavior changes for users. All existing functionality preserved.
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
Addresses #4932.
ANY_GIT_ERRORincludesTypeError,ValueError,AttributeError, andAssertionError— exception types that signal programming bugs, not git errors. When silently caught at 22+ call sites, real bugs become invisible: users see a vague message instead of a traceback, and bug reports are much harder to diagnose.Changes
Phase 1 — Observability (this PR)
Added
logger.debug()before every silentexcept ANY_GIT_ERRORblock across four files:aider/repo.py— 8 call sitesaider/coders/base_coder.py— 2 call sites (apply_updates,auto_commit)aider/commands.py— 5 call sites (do_run,cmd_commit,cmd_undo,cmd_diff)aider/main.py— 5 call sites (guessed_wrong_repo,make_new_repo,setup_git,check_gitignore,sanity_check_repo)Format is consistent across all sites:
exc_info=Trueensures the full traceback appears in debug logs, making hidden bugs fully visible.Redundancy fix
repo.py:384wrote(TypeError,) + ANY_GIT_ERROR— manually prependingTypeErrorwhen it is already a member of the tuple. Same issue inget_head_commitwith(ValueError,). Both simplified to plainANY_GIT_ERROR, removing the evidence of confusion noted in the issue.What this does NOT change
ANY_GIT_ERROR(that is Phase 2 work)Testing
Added
tests/basic/test_any_git_error_logging.pywith a test that:repo.ignored()to raiseTypeError(a programming bug)git_ignored_file()through the real code pathlogger.debugwas called with the correct function name, exception type, andexc_info=TrueNext steps (Phase 2)
Once Phase 1 is in and debug logs are available in the wild, the remaining work is to audit which call sites legitimately need
TypeError/AttributeError(where gitpython itself raises them) vs. which are cargo-cult catches that can be narrowed. Happy to continue that work in a follow-up PR.