Skip to content

fix: handle paths outside repository - #5628

Open
Totoro-qaq wants to merge 3 commits into
Aider-AI:mainfrom
Totoro-qaq:codex/fix-absolute-path-repo-check
Open

fix: handle paths outside repository#5628
Totoro-qaq wants to merge 3 commits into
Aider-AI:mainfrom
Totoro-qaq:codex/fix-absolute-path-repo-check

Conversation

@Totoro-qaq

Copy link
Copy Markdown

Fixes #5620

Summary

  • treat paths that cannot be normalized relative to the repository as untracked
  • prevent path_in_repo() and its is_dirty(path) caller from propagating ValueError
  • add a cross-platform regression test using an absolute path outside the temporary repository

Tests

  • pytest -q tests/basic/test_repo.py::TestRepo::test_path_outside_repo_is_not_tracked
  • pytest -q tests/basic/test_repo.py
  • pre-commit run --files aider/repo.py tests/basic/test_repo.py

@kvnloo

kvnloo commented Sep 1, 2026

Copy link
Copy Markdown

Live check on main 5dc9490: aider/repo.py normalize_path does Path(self.root)/path then relative_to(self.root), which raises ValueError for an absolute path outside the repo. ignored_file already catches that (returns True). path_in_repo at 574 does not. is_dirty(path) calls path_in_repo first, so an outside path never reaches "untracked => dirty"; it crashes.

PR head ef446b9 wraps normalize_path in path_in_repo, returns False on ValueError. is_dirty then returns True. TestPathOutsideRepoIsNotTracked uses Path.cwd().parent/"outside.txt" under GitTemporaryDirectory. That is the right pin.

I would merge. Optional follow-up, not blocking: the same relative_to hole is still live in whatever other callers skip the try (abs_root_path does not use relative_to).

)

An image outside the repository is accepted by /read-only from anywhere.
Promoting it with /add reaches GitRepo.path_in_repo() with an out-of-root
absolute path, which raised ValueError on main and killed the session.
With the path_in_repo() guard from this branch it is answered as
'not part of the repository' instead. Fails without the guard, passes with it.
test: pin /read-only + /add promotion of an outside image (Aider-AI#5620)Add regression coverage for /read-only followed by /add on an image
outside the repository.

Verify that the operation does not raise ValueError and that the image
remains read-only rather than being added as an editable file.

Test-only change; no production code changes.

Related to Aider-AI#5620.
For inclusion in Aider-AI#5628.
@CLAassistant

CLAassistant commented Sep 5, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ Totoro-qaq
❌ impartshadow
You have signed the CLA already but the status is still pending? Let us recheck it.

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 ValueError in path_in_repo()/is_dirty() when an edit block references an absolute path (session crash)

4 participants