Potential unhandled OSError in reference_parser.py #8879

Open
opened 2026-04-14 03:18:11 +00:00 by HAL9000 · 1 comment
Owner

Metadata

  • Commit Message: fix(tui): handle OSError in reference_parser _catalog os.walk
  • Branch: fix/tui-reference-parser-oserror

Background and Context

The _catalog function in src/cleveragents/tui/input/reference_parser.py does not handle a potential OSError that can be raised by os.walk. This can happen if the user does not have the correct permissions to access a directory or for other filesystem-related errors.

To Reproduce
Run the application in a directory where you don't have read permissions for a subdirectory.

Current Behavior
The function crashes with an unhandled OSError.

Code Snippet

# src/cleveragents/tui/input/reference_parser.py:53
for root, dirs, filenames in os.walk(cwd, followlinks=False):

Severity
Medium — can lead to a crash of the TUI, but the conditions to trigger it are less common.

Expected Behavior

The _catalog function should handle OSError gracefully — for example, by logging the error and skipping the inaccessible directory — so that the TUI continues to function rather than crashing.

Acceptance Criteria

  • os.walk errors in _catalog are caught and handled (e.g., logged and skipped) without propagating an unhandled exception.
  • The TUI remains operational when a subdirectory is inaccessible due to permission errors or other filesystem issues.
  • A unit test covers the scenario where os.walk raises an OSError and verifies the function does not crash.
  • Existing tests continue to pass.

Subtasks

  • Investigate the _catalog function in src/cleveragents/tui/input/reference_parser.py and identify all os.walk call sites that lack error handling.
  • Wrap the os.walk loop (or use the onerror callback parameter) to catch and log OSError exceptions.
  • Add a unit test that mocks os.walk to raise OSError and asserts the function handles it gracefully.
  • Verify no regressions by running the full TUI test suite.

Definition of Done

This issue should be closed when:

  • The _catalog function handles OSError from os.walk without crashing.
  • A test covering the error path is present and passing.
  • The fix is merged to the main branch.

Automated by CleverAgents Bot
Agent: new-issue-creator

## Metadata - **Commit Message**: `fix(tui): handle OSError in reference_parser _catalog os.walk` - **Branch**: `fix/tui-reference-parser-oserror` ## Background and Context The `_catalog` function in `src/cleveragents/tui/input/reference_parser.py` does not handle a potential `OSError` that can be raised by `os.walk`. This can happen if the user does not have the correct permissions to access a directory or for other filesystem-related errors. **To Reproduce** Run the application in a directory where you don't have read permissions for a subdirectory. **Current Behavior** The function crashes with an unhandled `OSError`. **Code Snippet** ```python # src/cleveragents/tui/input/reference_parser.py:53 for root, dirs, filenames in os.walk(cwd, followlinks=False): ``` **Severity** Medium — can lead to a crash of the TUI, but the conditions to trigger it are less common. ## Expected Behavior The `_catalog` function should handle `OSError` gracefully — for example, by logging the error and skipping the inaccessible directory — so that the TUI continues to function rather than crashing. ## Acceptance Criteria - [ ] `os.walk` errors in `_catalog` are caught and handled (e.g., logged and skipped) without propagating an unhandled exception. - [ ] The TUI remains operational when a subdirectory is inaccessible due to permission errors or other filesystem issues. - [ ] A unit test covers the scenario where `os.walk` raises an `OSError` and verifies the function does not crash. - [ ] Existing tests continue to pass. ## Subtasks - [ ] Investigate the `_catalog` function in `src/cleveragents/tui/input/reference_parser.py` and identify all `os.walk` call sites that lack error handling. - [ ] Wrap the `os.walk` loop (or use the `onerror` callback parameter) to catch and log `OSError` exceptions. - [ ] Add a unit test that mocks `os.walk` to raise `OSError` and asserts the function handles it gracefully. - [ ] Verify no regressions by running the full TUI test suite. ## Definition of Done This issue should be closed when: - The `_catalog` function handles `OSError` from `os.walk` without crashing. - A test covering the error path is present and passing. - The fix is merged to the main branch. --- **Automated by CleverAgents Bot** Agent: new-issue-creator
HAL9000 added this to the v3.7.0 milestone 2026-04-14 03:26:12 +00:00
Author
Owner

Triage Decision: VERIFIED — MoSCoW/Should Have

Real error handling gap: unhandled OSError in reference_parser.py can crash the TUI when file system operations fail (e.g., permission denied, disk full). Should be handled gracefully.

Priority/Medium — Error handling improvement; less critical than the ValueError crash (#8872).


Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: project-owner-pool-supervisor

✅ **Triage Decision: VERIFIED — MoSCoW/Should Have** Real error handling gap: unhandled `OSError` in `reference_parser.py` can crash the TUI when file system operations fail (e.g., permission denied, disk full). Should be handled gracefully. **Priority/Medium** — Error handling improvement; less critical than the `ValueError` crash (#8872). --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#8879
No description provided.