Skip to content

fix(repo): repo validate reports a task.json link that loops or is a directory (#910) - #952

Merged
xaleryb merged 6 commits into
intel:mainfrom
vchamarthi:issue-910-repo-validate-exits-5-with
Nov 21, 2026
Merged

xaleryb merged 6 commits into
intel:mainfrom
vchamarthi:issue-910-repo-validate-exits-5-with

Conversation

@vchamarthi

@vchamarthi vchamarthi commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

repo validate exited 5 with a traceback when task.json is a link to itself or to a directory, in a tree and at <dir>@rev. It now reports cannot read task.json: ... and exits 1. Fixes #910.

Changes

  • _read_task_json in dokimi/dokimi/repos/manifest.py reads task.json and catches OSError, RuntimeError and SourceError besides the two JSON errors. It is a function of its own, with its result named unreadable so it does not reuse the later problem, because a third except in _check_task grew its complexity past the baseline.
  • Test in dokimi/tests/test_repo_manifest.py over loop and directory link, tree and @HEAD.
  • Changelog fragment.
  • Second test makes WorkTree._resolve raise RuntimeError, which Path.resolve does for a loop before Python 3.13.

Risk

Low. Only a task.json that could not be read before changes outcome: an error line and exit 1 instead of a traceback and exit 5. The error text for invalid JSON is unchanged.

Testing

python -m pytest -q -p no:cacheprovider tests/test_repo_manifest.py tests/test_growth_ratchet.py passes, and ruff check and mypy pass on dokimi/repos/manifest.py. The new test fails on main in all four cases.

Open questions

None

Revert

Plain revert. Nothing stored is left behind.

Checklist

  • Tests added/updated and pytest passes
  • ruff, mypy, and schema checks pass
  • Docs updated (or N/A) — see the docs-drift checklist in CONTRIBUTING.md
  • Self-reviewed per "Before opening a PR" in AGENTS.md
  • Each new raise/exit and test names the doc, contract or issue it traces to
  • No ad-hoc run artifacts committed
  • New files carry the SPDX license header (or are exempt in .github/.licenserc.yaml)
Checklist evidence
  • Tests added/updated and pytest passes: 1 test file(s) changed; the whole suite passed; 2 proof(s) fail before the change
  • ruff, mypy, and schema checks pass: passed: ruff check / schema-check (Static checks (ruff, schema, zizmor, licenses, pre-commit, bandit, secrets, changelog, schema com...), typecheck / mypy (mypy)
  • Docs updated (or N/A): updated: dokimi/docs/repo-evaluation-contract.md
  • Self-reviewed per "Before opening a PR" in AGENTS.md: second reader: 2 round(s), nothing left open; mutation of changed lines ran
  • Each new raise/exit and test names the doc, contract or issue it traces to: every new error path and test names a doc, contract or issue
  • No ad-hoc run artifacts committed: 1 added file(s), none a run's output
  • New files carry the SPDX license header (or are exempt in .github/.licenserc.yaml): no new source file

Fixes #910.

…directory (intel#910)

_check_task caught only JSONDecodeError and UnicodeDecodeError around the
task.json read, so a link to itself or to a directory ended in a traceback
and exit 5, in a tree (OSError) and at <dir>@rev (SourceError). Both are now
a 'cannot read task.json' error and exit 1. Fixes intel#910.

Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
@codecov-commenter

codecov-commenter commented Nov 19, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 95.91%. Comparing base (2ab246c) to head (f485673).
⚠️ Report is 40 commits behind head on main.

Files with missing lines Patch % Lines
dokimi/dokimi/repos/manifest.py 90.90% 1 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #952      +/-   ##
==========================================
+ Coverage   95.84%   95.91%   +0.06%     
==========================================
  Files         442      449       +7     
  Lines       58843    59481     +638     
  Branches    10148    10254     +106     
==========================================
+ Hits        56397    57050     +653     
+ Misses       1521     1509      -12     
+ Partials      925      922       -3     
Files with missing lines Coverage Δ
dokimi/dokimi/repos/manifest.py 94.87% <90.90%> (+0.52%) ⬆️

... and 67 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…tel#910)

The contract's task.json section now says that an invalid, non-object or
unreadable task.json (a link to itself or to a directory) is an error line
and exit 1.

Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the change to report unreadable task.json links as validation errors.

No open issues 🎉

What changed in this PR

0 new findings; nothing to fix.

Fixes #910 by making repo validate report unreadable task.json links as validation errors with exit code 1, rather than a traceback and exit code 5.

Changes:

  • Extracts task JSON reading into a helper that handles read failures while preserving invalid-JSON messages.
  • Adds regression coverage for self-links and directory links in working trees and committed revisions, plus pre-Python 3.13 loop errors.
  • Documents the validation behavior and adds a changelog entry.
File Description
dokimi/​tests/​test_repo_manifest.py Adds unreadable-link regression tests.
dokimi/​dokimi/​repos/​manifest.py Converts task JSON read failures into validation errors.
dokimi/​docs/​repo-evaluation-contract.md Documents error reporting and exit code 1.
dokimi/​changelog.d/​20261118_170000_task-json-link-validate.md Records the fix for #910.

Review effort: Balanced

@exai-bot

exai-bot commented Nov 20, 2026 •

Copy link
Copy Markdown

✅ OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s).

CI at f485673: 25 passing, 3 skipped.

Review details
  • Commit reviewed: f485673 against merge base ca60a4c
  • Coverage: 1 files in 1 groups
  • Engine: OpenCodeReview v1.13.5-exai.4.8f73eada, us.openai.gpt-6.1-sol
  • Usage: 46k tokens (26k from cache), 14s
  • Tool calls: 6 (4 file_read, 2 code_search)
  • dokimi/tests/test_repo_manifest.py: 1 file

…d git show is raised

Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
…eported

Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>

@vlad-perevezentsev vlad-perevezentsev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 LGTM · checked e77ebc1 · nothing required from @vchamarthi

🔀 Merge: safe now · merges cleanly into current main, 26 commits behind, and its tests pass on the merge · after it, #1044 and #787 need a rebase (repos/manifest.py)

✅ make ci-local --offline: 23,646 passed · ⚠️ two Ctrl-C timeout tests (test_docker_cmd.py, test_repo_host.py) timed out under load and pass on rerun; schema_compat fails from newer main, not from this PR · ✅ the new tests fail on the base and at 792671f

A task.json link that loops, names a directory or nothing, or leaves the repository is now an error: line in both trees.

Fixed in this branch, up to e77ebc1:

  • A working tree showed the host's absolute path and an [Errno], and a failed git show read as a task error: aa83e9e reads tree.resolve(where) and catches only OSError and SourceArgumentError.
  • Dangling and out-of-repo links were untested and undocumented: e77ebc1 adds both to the test, the contract and the fragment.

Comment thread dokimi/dokimi/repos/manifest.py Resolved
…ctory (intel#910)

A task.json link such as missing/../missing.json at <dir>@rev raised
_NoSuchPath out of _read_task_json instead of recording the task error.
It is now caught with the other unreadable-link cases, with a test case.

Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
@vchamarthi

Copy link
Copy Markdown
Contributor Author

🟢 Ready for re-review · 1 commit on issue-910-repo-validate-exits-5-with (e77ebc1..ca60a4c)

Next: a re-review of the new head.

Changes

  • _read_task_json catches _NoSuchPath.

Threads and comments

  • 1 fixed; each answered in its thread.

Verified on the new head: ✅ 1/1 tests fail before the fix, pass after · ✅ full suite with main merged in: 24313 passed, 1 failure that main has too · ✅ second reader: nothing raised

What each test shows
  • link past an absent directory is reported at HEAD and in the tree: fails before, passes after.
  • Left to GitHub's own checks: agent-quality.yml:external-catalog-smoke, ci.yml:static / pre-commit, ci.yml:static / Install gitleaks (unsupported host: needs installed native gitleaks at the workflow's pinned version), ci.yml:static / Scan commits (unsupported host: needs installed native gitleaks at the workflow's pinned version), ci.yml:fidelity / Install the pinned Claude Code, ci.yml:test-latest, ci.yml:package-smoke, ci.yml:windows-smoke.

…ntel#910)

Dropping OSError from the except in _read_task_json left every test green, though
a task.json that raises PermissionError on open then exits 5 with a traceback.

Signed-off-by: Alexander Rybkin <alexander.rybkin@intel.com>
@xaleryb

xaleryb commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Pushed f485673, a test-only commit: a task.json that raises PermissionError on open is reported as a validation error, not raised. Dropping OSError from the except in _read_task_json left every test green while repo validate exited 5 with a traceback; with this test that change is red. Nothing else is open from our side; I will approve once CI is green on the new head.

@xaleryb xaleryb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved on f485673. CI is green on the head. Checked 12 task.json shapes (loops, directory, dangling, past an absent directory, outside the repo, good links): main exits 5 with a traceback, the head exits 1 with the file named. The added test pins that an unopenable task.json is reported, not raised.

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.

repo validate exits 5 with a traceback when task.json links to itself or to a directory, in a tree and at <dir>@rev

6 participants