Summary
When using the Slack integration on Windows, the bot frequently responds with the error:
Directory must stay within workspace root: //?/c:/users/...
Root Cause
In apps/opencode-router/src/bridge.ts, the isWithinWorkspaceRoot function uses path.relative(workspaceRoot, resolved).
On Windows, workspaceRoot can sometimes include the long path prefix (e.g., //?/c:/), while resolved resolves to a standard absolute path (e.g., c:\...).
Node.js path.relative treats these as different roots and returns an absolute path. The check if (isAbsolute(relativePath)) return false; then incorrectly fails the validation, blocking legitimate directory access.
Steps to reproduce
- Run Openwork on Windows.
- Connect a Slack bot via opencode-router.
- Attempt to interact with the bot in Slack.
- The bot replies with the directory boundary error.
Suggested Fix
Normalize the workspaceRoot to strip the //?/ prefix before performing path comparisons, or use a more robust path normalization strategy for Windows paths in isWithinWorkspaceRoot.
Summary
When using the Slack integration on Windows, the bot frequently responds with the error:
Directory must stay within workspace root: //?/c:/users/...Root Cause
In
apps/opencode-router/src/bridge.ts, theisWithinWorkspaceRootfunction usespath.relative(workspaceRoot, resolved).On Windows,
workspaceRootcan sometimes include the long path prefix (e.g.,//?/c:/), whileresolvedresolves to a standard absolute path (e.g.,c:\...).Node.js
path.relativetreats these as different roots and returns an absolute path. The checkif (isAbsolute(relativePath)) return false;then incorrectly fails the validation, blocking legitimate directory access.Steps to reproduce
Suggested Fix
Normalize the
workspaceRootto strip the//?/prefix before performing path comparisons, or use a more robust path normalization strategy for Windows paths inisWithinWorkspaceRoot.