Skip to content

Patch tool should fail fast on paths outside workspace #11113

Closed

Description

@ilepn

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)

  1. Start OpenCode in a workspace on C:
    opencode C:/Users/me/project
  2. 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

Activity

  1. github-actions commented on Jan 29, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Related enhancement proposals:

    Feel free to ignore if none of these address your specific case.

  2. github-actions commented on Mar 31, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions