Repository navigation
fix(doctor): report files without read permission instead of crashing - #748
Merged
kstonekuan merged 1 commit intoOct 29, 2026
Merged
Conversation
hflow doctor caught FileNotFoundError and ValueError per file, so a file the user cannot open raised PermissionError out of the loop. The run ended with a traceback and the reports for every later file were lost. Catch OSError so it is reported in place as [error] unreadable, the same as a missing file.
Contributor
[Low impact] The PR appears safe to merge.
|
kstonekuan
approved these changes
Oct 29, 2026
kstonekuan
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the fix. Ruff, ty, the permission regression test, and both Python CI jobs pass. Merging.
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
hflow doctornow reports a file it cannot open (permission denied) in place as[error] unreadable: ...and keeps going, instead of exiting with a traceback.Why
_command_doctorcaughtValueErrorandFileNotFoundErrorper file. Opening a file the user has no read permission for raisesPermissionError, which is anOSErrorbut not aFileNotFoundError, so it escaped the loop. The run stopped and every report after that file was lost, which is the thing docs/FORMAT.md says doctor avoids ("An unreadable or unparseable path is reported in place ... and the run continues with the remaining files").Repro on main:
After:
locked.mcapgets[error] unreadable: [Errno 13] Permission denied: ...andNOT CONFORMING,episode.mcapstill gets its report, and the exit code is 1 (or 2 if nothing could be diagnosed), per the existing exit code rules.The fix is to catch
OSErrorin the CLI loop.diagnose()itself is unchanged, so library callers still get the exception. CLI only, no stored bytes change, so no behavior version bump.Validation
uv run pytest -q tests/test_doctor.py -k permissionon main: fails with thePermissionErrorabove. With the fix: passes.uv run pytest -q -n 4: 2571 passed, 49 skipped.uv run ruff check --fix,uv run ruff format,uv run ty check: clean.The new test is skipped when running as root, since root can open a mode 000 file.
Checklist
uv run ruff check --fix,uv run ruff format, anduv run ty check.Need help on this PR? Tag
@codesmith-botwith what you need.