Repository navigation
fix(repo): budget names a linked directory and a link loop as the reason (#1331) - #1424
Conversation
…son (intel#1331) `repo budget` gave "not found, broken link, or outside tree" for every unreadable guidance link except a decode error or a FIFO. A guidance link to a directory and a symbolic link loop now have their own error types, raised where the trees already detect them, and `_unreadable_reason` maps them to "links to a directory" and "symbolic link loop". Fixes intel#1331 Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 6 selected item(s). CI at Test notes (1)
Review details
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1424 +/- ##
=======================================
Coverage 96.30% 96.30%
=======================================
Files 515 515
Lines 68905 68966 +61
Branches 11932 11940 +8
=======================================
+ Hits 66360 66420 +60
+ Misses 1568 1567 -1
- Partials 977 979 +2
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
4 open issues
WorkTree._readable()only translatesRuntimeErrorintoLinkLoopError, but link-loop… · NewWorkTree.resolvecurrently converts anyOSErrorraised by_resolve()intoLinkLoopError.… · New On Windows,Path.symlink_to()often requirestarget_is_directory=Truewhen the target is a… · New Defininggitas alambdaforces a# noqa: E731and makes the helper harder to extend/debug.… · New
What changed in this PR
This PR makes repo budget warnings more specific by introducing typed errors for symlink loops and symlinks to directories, and mapping them to clearer human-readable reasons (fixing #1331).
Changes:
- Add
LinkLoopErrorandLinkToDirectoryErrorasSourceArgumentErrorsubclasses and raise them fromWorkTree/GitTreeresolution paths. - Update
repo budget’s unreadable-reason mapping to emit “symbolic link loop” / “links to a directory”. - Add targeted tests and a changelog fragment for the new warning wording.
| File | Description |
|---|---|
| dokimi/tests/test_repo_budget_link_reasons.py | Adds regression tests ensuring repo budget names “links to a directory” and “symbolic link loop”. |
| dokimi/dokimi/repos/source_errors.py | Introduces typed exceptions so callers can distinguish loop vs directory-link errors. |
| dokimi/dokimi/repos/source.py | Raises the new typed exceptions from WorkTree/GitTree resolution and readability checks. |
| dokimi/dokimi/repos/links.py | Makes internal _LinkLoop derive from LinkLoopError to preserve typing. |
| dokimi/dokimi/repos/budget.py | Maps LinkLoopError / LinkToDirectoryError to the new warning strings. |
| dokimi/changelog.d/20261129_120000_budget-link-reasons.md | Documents the improved warning wording in the changelog. |
Review effort: Lite
| except (RuntimeError, OSError) as exc: # a link loop (RuntimeError before Python 3.13); typed so `repo budget` names it (#1331) | ||
| raise LinkLoopError(f"too many levels of symbolic links: {path}") from exc |
There was a problem hiding this comment.
Fixed in 25f14f3: WorkTree.resolve now raises LinkLoopError only for RuntimeError or an OSError with ELOOP; any other OSError is a SourceArgumentError with its own message, and a test covers both.
There was a problem hiding this comment.
This was already fixed in 25f14f3: WorkTree.resolve raises LinkLoopError only for RuntimeError or ELOOP, and tests/test_repo_budget_link_reasons.py::test_only_an_eloop_while_resolving_is_a_link_loop covers ELOOP and EACCES.
Mutation of changed linesAt 8c1356e: 22 caught · 0 missed · 6 inconclusive This is not a clean result:
Warning only: a missed break does not fail the job. Updated on every push; the full report is in the ci run summary. |
…y resolve Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
vlad-perevezentsev
left a comment
There was a problem hiding this comment.
🟢 LGTM · re-checked 25f14f3 · nothing required from @vchamarthi
🔀 Merge: safe now · merges cleanly into current main, 0 commits behind · after it, #1402 needs a rebase (repos/links.py, repos/source.py), and #1328, #1321, #1190 and #1416 (repos/source.py)
✅ make ci-local --offline: 31,402 passed, 117 skipped · ✅ 4 of the 5 original tests fail on the base · ✅ the junction and ELOOP tests fail with their fix reverted · ✅ Windows (Server 2025, Python 3.13): tests/test_repo_budget_link_reasons.py 10 passed, a real junction included
repo budget now names a linked directory and a link loop correctly, in a work tree and in a commit.
Disagreed with @Copilot on the ELOOP path and on target_is_directory: replied in their threads.
Fixed in this branch, up to 25f14f3:
- The GitTree link-to-directory branch had no test: 0cd6153 runs the test on a commit too and checks
resolve(). - A Windows junction to a directory got the generic reason: 22ec887 checks
_is_link(). - The fallback comment still named a loop: b046fdc.
WorkTree.resolvecalled everyOSErrora loop (the @Copilot thread): 25f14f3 keeps it forELOOPonly.
Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
- _readable translated only RuntimeError, so an ELOOP OSError escaped untyped; resolve and _readable now share _loop_checked. - The link tests follow main's renames (link_text, files listed by hand for the mocked junction); _link marks directory targets and the git helper is a def. Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
|
This is ready for another look: I've pushed 2 commits on Changes:
Threads:
What I checked on the new commit: the 1 test of the fix pass; the full test suite passes with main merged in (32,270 tests), apart from 1 failure main has too. What each test shows
|


Summary
repo budgetprintednot found, broken link, or outside treefor a guidance link to a directory and for a symlink loop, thoughrepo scannames both. It now sayslinks to a directoryorsymbolic link loop. Fixes #1331. Related: #1272, #1329.Changes
dokimi/repos/source_errors.py: newLinkLoopErrorandLinkToDirectoryError, bothSourceArgumentError.dokimi/repos/source.py:WorkTree.resolve,GitTree._followandGitTree.resolveraise them;WorkTree._readableraisesLinkToDirectoryErrorfor a symlink to a directory, whichread_textused to report as a bareIsADirectoryError.dokimi/repos/links.py:_LinkLoopderives fromLinkLoopError.dokimi/repos/budget.py:_unreadable_reasonmaps the two types.tests/test_repo_budget_link_reasons.py: the new tests, in their own file becausetests/test_repo_budget.pyis near the 1000 line cap.WorkTree._readablealso turns aRuntimeErrorfrom a link loop (Python before 3.13) intoLinkLoopError.Risk
WorkTree.read_textandread_byteson a symlink to a directory now raiseLinkToDirectoryError(aValueError) instead ofIsADirectoryError, which matches whatGitTreealready raised. I think a caller that catches onlyOSErroraround such a read would now see it escape; I did not find one indokimi/repos. The newraisesites carry a comment naming #1331.Testing
Four tests in
tests/test_repo_budget_link_reasons.py: a directory link forAGENTS.mdandCLAUDE.md, a self-link loop in a work tree and in a commit, a loop reported asRuntimeErroras Python before 3.13 does, and a dangling link that keeps the old text. That file,tests/test_repo_budget.py,tests/test_repo_source_links.pyandtests/test_growth_ratchet.pypass together (179 passed, 2 skipped).Open questions
None beyond the choices listed by the program.
_unreadable_reasonover Reading the exception message inrepo budget: repo scan mishandles guidance links with invalid or non-UTF-8 targets #1272 chose to decide by type, andtest_unreadable_reason_goes_by_the_error_type_not_its_wordspins that. Is that the behaviour you want?WorkTree._readableraisesLinkToDirectoryErrorfor a symlink to a directory over MappingIsADirectoryErrorin_unreadable_reason: A plain directory would then also read 'links to a directory', andGitTreealready raises this type. Is that the behaviour you want?Revert
A plain revert restores the old text. Nothing is stored.
Checklist
None.
pytestpassesruff,mypy, and schema checks passAGENTS.mdraise/exit and test names the doc, contract or issue it traces to.github/.licenserc.yaml)Checklist evidence
pytestpasses: 1 test file(s) changed; suite: 31624 passed; 1 failing test(s) fail on the base branch too: tests/test_repo_compare_interval.py::test_the_row_p_places_zero_where_large_deltas_round_p_at_zero_apart; 3 of 4 proof(s) fail before the change; 1 pin behaviour the base code already hadruff,mypy, and schema checks pass: passed: ci.yml:static / ruff check, ci.yml:typecheck / mypy, ci.yml:static / schema-check, ci.yml:static / schema_compat vs the PR baserepo budgetwarning wording is described only by the changelog fragment added here.AGENTS.md: nothing left open; mutation of changed lines ranraise/exit and test names the doc, contract or issue it traces to: every new error path and test names a doc, contract or issue.github/.licenserc.yaml): every new source file carries the headerFixes #1331.