Skip to content

fix(web): handle PermissionError when listing directory entries#1692

Open
Jesse-XIE wants to merge 1 commit intoMoonshotAI:mainfrom
Jesse-XIE:fix/macos-permission-error
Open

fix(web): handle PermissionError when listing directory entries#1692
Jesse-XIE wants to merge 1 commit intoMoonshotAI:mainfrom
Jesse-XIE:fix/macos-permission-error

Conversation

@Jesse-XIE
Copy link
Copy Markdown
Contributor

@Jesse-XIE Jesse-XIE commented Apr 1, 2026

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

  • I have read the CONTRIBUTING document.
  • I have linked the related issue, if any.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have run make gen-changelog to update the changelog.
  • I have run make gen-docs to update the user documentation.

Open with Devin

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.
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View 2 additional findings in Devin Review.

Open in Devin Review


## 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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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`.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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.

1 participant