Summary
When patch/apply_patch receives a file path outside the current workspace root, it should fail fast with a clear error and non-zero status instead of silently "succeeding" or writing to the wrong location.
Repro (Windows, but should be general)
- Start OpenCode in a workspace on C:
opencode C:/Users/me/project
- Apply a patch targeting an absolute path on D:
*** Update File: D:/.toolbox/docs/uv-install.md
Observed: patch reports success but no file is created/updated under D:, or paths are mis-interpreted.
Expected: validation error indicating path outside workspace root.
Expected behavior
- Normalize each patch target path.
- If target path resolves outside workspace root, abort before making changes.
- Return a non-zero tool error status, e.g.
EOUTSIDE_ROOT, with a clear message:
"Path outside workspace root. Start OpenCode in that directory or use an allowed root."
Nice-to-have (optional)
- Configurable allowlist of additional roots (multi-root).
- Or prompt for explicit approval when patch targets a path outside root.
Related
Summary
When
patch/apply_patchreceives a file path outside the current workspace root, it should fail fast with a clear error and non-zero status instead of silently "succeeding" or writing to the wrong location.Repro (Windows, but should be general)
opencode C:/Users/me/project*** Update File: D:/.toolbox/docs/uv-install.mdObserved: patch reports success but no file is created/updated under D:, or paths are mis-interpreted.
Expected: validation error indicating path outside workspace root.
Expected behavior
EOUTSIDE_ROOT, with a clear message:"Path outside workspace root. Start OpenCode in that directory or use an allowed root."
Nice-to-have (optional)
Related