Skip to content

fix(octop): guard Path.iterdir() with OSError in teams router and browser setup - #2659

Closed
TrueFurina wants to merge 1 commit into
TencentCloud:mainfrom
TrueFurina:r73-teams-setup-iterdir
Closed

TrueFurina wants to merge 1 commit into
TencentCloud:mainfrom
TrueFurina:r73-teams-setup-iterdir

Conversation

@TrueFurina

Copy link
Copy Markdown

Summary

Wrap the final two bare Path.iterdir() calls in Octop production code with ry/except OSError. Two files, one commit.

Files changed

�pi/routers/teams.py — eam_template_files()`n

Serves default team workspace markdown templates from TEMPLATE_DIR. Gated by is_dir() which is insufficient on Windows — the directory can exist but be ACL-restricted or locked by antivirus. On OSError fall back to an empty file list.

infra/control/browser/setup.py — browser cleanup flow

Iterates the Playwright Chrome profiles root to stop Octop-managed processes before deleting Playwright binaries. An unhandled PermissionError here would abort the entire uninstall/reset SSE stream mid-way. On OSError skip the per-profile step and continue with Chromium dir removal.

Pattern

This closes out the Path.iterdir() defensive-itdir sweep across both repos: server.py (#2657), skill_packages.py + init.py (#2658), harness workspace/loader/skill/slash_router (#191-#193), skill_package_store.py, workspace_catalog.py, and browser_media.py. Future sweeps can focus on Path.glob/
glob onerror and os.scandir paths.

…wser setup

Final two bare iterdir() calls on user-facing paths in Octop production code. Both are gated by is_dir() which only verifies the directory entry exists, not that the process has read permission. On Windows, ACL restrictions or antivirus file locks can still raise PermissionError when iterdir() runs.

1. api/routers/teams.py: team_template_files() serves default workspace templates from a package-level TEMPLATE_DIR. Wrap sorted(TEMPLATE_DIR.iterdir()) in try/except OSError and fall back to returning no templates (empty list).

2. infra/control/browser/setup.py: browser removal flow iterates profiles_root to stop Chrome processes. Wrap sorted(profiles_root.iterdir()) in try/except OSError so the cleanup degrades gracefully to skipping that step instead of aborting the whole uninstall/reset SSE stream.
@jubaoliang jubaoliang closed this Oct 31, 2026
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.

2 participants