Repository navigation
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
There was a problem hiding this comment.
The change looks sound. I reproduced the empty 500 on the base by running your new unreadable-folder case as a non-root user (root skips it here). With this PR, all four endpoints return 403 LocationAccessDeniedError and recover to 200 once the folder mode is restored. fetch.test.ts passes and tsc -b in packages/server is clean.
Public API (additive, backwards compatible):
- New
LocationAccessDeniedErrorschema (_tag,location,message, HTTP 403) in@opencode/protocol/errors,openapi.jsonand the generated client types. 403is added to the declared errors of every location-scoped endpoint, and toLocationMiddlewareandSessionLocationMiddlewarein the protocol client. These requests used to fail with an undeclared500.- TypeScript callers that switch exhaustively over an endpoint's error union get one more member to handle.
Non-blocking follow-up: the app (packages/app/src/workspaces/location.tsx) and the TUI (packages/tui/src/context/location.tsx) treat only LocationNotFoundError as final. A 403 is still retried like the old 500, and there is no prompt equivalent to the missing-folder one. Showing the new error there would close the remaining user-facing part of #50951.
Related: #50951
There was a problem hiding this comment.
The new commit only shortens the macOS hint in the LocationAccessDeniedError message, and I have nothing new to flag. I re-ran the missing-folder and unreadable-folder tests in fetch.test.ts as a non-root user, and both pass. The public API is the same as in my last review: LocationAccessDeniedError (403) is added to the protocol, OpenAPI spec and generated client, which is backwards compatible. Only the macOS message text changed.
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Refs #50951, #56479
Type of change
What does this PR do?
When the server cannot read a project folder, every location-scoped request returned
500with an empty body. A common cause is macOS privacy settings blocking~/Documents. The app could only showClientError: UnexpectedStatus: 500. Now the server returns a typed403that names the folder.500, empty bodyClientError: UnexpectedStatus: 500403 LocationAccessDeniedErrorLocation access denied: <folder>. On macOS, the message adds where to check.DirectoryAccessDeniedError, but instance boot keeps it a defect.locationErrorsinpackages/server/src/location.tsis the one function that every location boundary uses. It now translates that defect, and any other defect is re-raised unchanged.LocationAccessDeniedErrornext toLocationNotFoundErroron every endpoint and middleware that declares it, then regenerates the client andopenapi.json.Check System Settings > Privacy & Security > Files & Folders.{ "_tag": "LocationAccessDeniedError", "location": { "directory": "/Users/me/Documents/Default Project" }, "message": "Location access denied: /Users/me/Documents/Default Project. Check System Settings > Privacy & Security > Files & Folders." }How did you verify your code works?
packages/server/test/fetch.test.tsis now a table that also covers an unreadable folder (chmod 000):403on location, session and form endpoints, then200after the mode is restored. Windows and root skip that case.realpathfail withEPERM, the same code a macOS privacy denial gives.GET /api/modelreturned500with an empty body before this change and403 LocationAccessDeniedErrorafter it.Visual
Screenshots / recordings
Not applicable. The app already shows a declared error's message. This PR makes the server send one.
Checklist
Added by the opencode bot (AI-generated).
Related: #50951
Public API: adds LocationAccessDeniedError (403) to the protocol, OpenAPI spec and generated client for all location-scoped endpoints (backwards compatible)