fix(web): handle PermissionError when listing directory entries#1692
fix(web): handle PermissionError when listing directory entries#1692Jesse-XIE wants to merge 1 commit intoMoonshotAI:mainfrom
Conversation
When the work directory contains entries that the process cannot access (e.g. ~/.Trash on macOS due to TCC, or permission-restricted directories on Linux), iterdir() or stat() raises PermissionError, causing the get_session_file endpoint to return HTTP 500. Wrap iterdir() and per-entry stat/is_dir calls with try/except to gracefully skip inaccessible entries instead of crashing.
|
|
||
| ## Unreleased | ||
|
|
||
| - Web: Fix file listing crash on macOS when encountering permission-restricted entries (e.g. `.Trash`) — `PermissionError` on `iterdir()` now returns an empty listing, and individual entries that raise `PermissionError` / `OSError` on `stat()` are silently skipped |
There was a problem hiding this comment.
🟡 Manually edited auto-generated English changelog violating repo rules
docs/en/release-notes/changelog.md is explicitly documented as auto-generated from the root CHANGELOG.md via the sync script (docs/scripts/sync-changelog.mjs). The docs/AGENTS.md:185 rule states: "The English changelog (docs/en/release-notes/changelog.md) is auto-generated from the root CHANGELOG.md. Do not edit it manually." This PR manually edits the file, which will be overwritten the next time the sync script runs (during npm run dev or npm run build). The root CHANGELOG.md is already updated with the same entry, so the correct workflow is to only edit the root file and let the sync script propagate the change.
Prompt for agents
Remove the manual edit to docs/en/release-notes/changelog.md (line 7). This file is auto-generated from the root CHANGELOG.md by the sync script at docs/scripts/sync-changelog.mjs. Instead, only edit the root CHANGELOG.md (which is already done in this PR) and run `npm run sync` from the docs/ directory to regenerate the English changelog, or let it auto-sync during the next `npm run dev` / `npm run build`.
Was this helpful? React with 👍 or 👎 to provide feedback.
Related Issue
no
Description
When the work directory contains entries that the process cannot access (e.g. ~/.Trash on macOS due to TCC, or permission-restricted directories on Linux), iterdir() or stat() raises PermissionError, causing the get_session_file endpoint to return HTTP 500.
Wrap iterdir() and per-entry stat/is_dir calls with try/except to gracefully skip inaccessible entries instead of crashing.
Checklist
make gen-changelogto update the changelog.make gen-docsto update the user documentation.