Repository navigation
fix(octop): guard log_dir.iterdir() with OSError in server log helpers - #2657
Closed
TrueFurina wants to merge 1 commit into
Closed
TrueFurina wants to merge 1 commit into
TrueFurina wants to merge 1 commit into
Conversation
Both _migrate_legacy_rotated_logs() and _iter_rotated_logs() check log_dir.is_dir() before calling iterdir(), but is_dir() only verifies the directory entry exists, not that the process has read permission. On Windows the log directory can be ACL-restricted or locked by an antivirus or log viewer process, causing PermissionError to crash the server startup or log-migration path. Wrap each iterdir() in try/except OSError and degrade gracefully (return early / empty generator).
This was referenced Oct 30, 2026
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
Wrap two bare log_dir.iterdir() calls in src/octop/infra/server.py with ry/except OSError.
Problem
Both _migrate_legacy_rotated_logs() and _iter_rotated_logs() gate on log_dir.is_dir() before iterating. On Windows, is_dir() only checks that the directory entry exists — it does not guarantee read permission. ACLs, antivirus locks, or a handle held by an external log viewer can all raise PermissionError (a subclass of OSError) the moment iterdir() runs. An unhandled exception here would crash server startup or the rotated-log enumeration path.
Fix
This is part of the broader defensive-itdir pattern also applied to skill_package_store.py, workspace_catalog.py, and the harness CLI commands (PR #191, #192, #193).