Skip to content

Test OSError in _full_scandir_discovery is_dir() (#896)#900

Merged
microsasa merged 1 commit intomainfrom
fix/896-test-is-dir-oserror-76bfa0ffb5e93093
Apr 10, 2026
Merged

Test OSError in _full_scandir_discovery is_dir() (#896)#900
microsasa merged 1 commit intomainfrom
fix/896-test-is-dir-oserror-76bfa0ffb5e93093

Conversation

@microsasa
Copy link
Copy Markdown
Owner

Summary

Adds a test for the untested except OSError branch in _full_scandir_discovery() (parser.py lines 307-310).

When DirEntry.is_dir(follow_symlinks=False) raises OSError (e.g., broken bind-mount, stale NFS entry, security module denying stat), the entry is correctly treated as a non-directory and skipped. This test verifies that behavior using a MagicMock DirEntry whose is_dir() raises OSError.

Follows the same pattern as test_stat_failure_on_entry_skipped in test_vscode_parser.py.

Closes #896

Generated by Issue Implementer · ● 8.4M ·

Cover the untested except-OSError branch in _full_scandir_discovery()
(parser.py lines 307-310). When DirEntry.is_dir(follow_symlinks=False)
raises OSError, the entry is correctly treated as a non-directory and
skipped. This test verifies that behavior using a MagicMock DirEntry,
mirroring the existing test_stat_failure_on_entry_skipped pattern in
test_vscode_parser.py.

Closes #896

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@microsasa microsasa added the aw Created by agentic workflow label Apr 10, 2026
@microsasa microsasa enabled auto-merge April 10, 2026 09:39
@microsasa microsasa added the aw Created by agentic workflow label Apr 10, 2026
Copilot AI review requested due to automatic review settings April 10, 2026 09:39
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds targeted unit coverage for a previously untested defensive branch in session discovery (_full_scandir_discovery) so filesystem edge cases that raise OSError from DirEntry.is_dir(follow_symlinks=False) are validated and won’t regress.

Changes:

  • Import _full_scandir_discovery into tests/copilot_usage/test_parser.py.
  • Add a new test ensuring DirEntry.is_dir() raising OSError results in the entry being treated as non-directory and skipped (issue #896).

@microsasa microsasa added the aw-quality-gate-approved Quality gate approved the PR label Apr 10, 2026
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Low-impact test-only addition covering the OSError handling path in _full_scandir_discovery (parser.py lines 307-310). The test properly mocks os.scandir with a DirEntry whose is_dir() raises OSError, verifies the entry is silently skipped, and asserts the call signature. Follows existing test conventions, CI is green. Auto-approving for merge.

@microsasa microsasa merged commit b1c6203 into main Apr 10, 2026
8 checks passed
@microsasa microsasa deleted the fix/896-test-is-dir-oserror-76bfa0ffb5e93093 branch April 10, 2026 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aw Created by agentic workflow aw-quality-gate-approved Quality gate approved the PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[aw][test audit] _full_scandir_discovery() OSError handler for is_dir() is untested

2 participants