Skip to content

Fix TypeError when working_tree_dir is None#4973

Open
zerone0x wants to merge 1 commit intoAider-AI:mainfrom
zerone0x:fix/issue-4971-none-working-tree
Open

Fix TypeError when working_tree_dir is None#4973
zerone0x wants to merge 1 commit intoAider-AI:mainfrom
zerone0x:fix/issue-4971-none-working-tree

Conversation

@zerone0x
Copy link
Copy Markdown

Summary

  • Guard against None value from repo.working_tree_dir in GitRepo.__init__ to prevent TypeError
  • When working_tree_dir is None (e.g., bare repositories), raise FileNotFoundError with a descriptive message instead of crashing with an uncaught TypeError in pathlib.py
  • Added test for bare repository handling

Context

The crash occurs because self.repo.working_tree_dir returns None for bare git repositories, and this None gets passed to safe_abs_path() -> Path(res).resolve(), which raises TypeError.

The fix raises FileNotFoundError early in GitRepo.__init__, which is already the expected exception type (caught in main.py line 921). The error message matches the existing sanity_check_repo() message for consistency.

Test plan

  • Added test_bare_repo_raises_file_not_found test
  • All 22 existing tests in tests/basic/test_repo.py pass

Fixes #4971

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

Guard against None value from repo.working_tree_dir in GitRepo.__init__
by raising FileNotFoundError before passing it to safe_abs_path. This
prevents the uncaught TypeError when aider is run in a bare git
repository.

Fixes Aider-AI#4971

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

Uncaught TypeError in pathlib.py line 373

1 participant