Skip to content

Fixes #37650 - #41671

Closed
asiimhusain wants to merge 4 commits into
anomalyco:devfrom
asiimhusain:fix-permission-metadata
Closed

asiimhusain wants to merge 4 commits into
anomalyco:devfrom
asiimhusain:fix-permission-metadata

Conversation

@asiimhusain

Copy link
Copy Markdown

Issue for this PR

tools: optional search metadata breaks pending permission listing
#37650

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When executing glob and grep tools without optional parameters, params.path and params.include are undefined. Previously, these were passed directly into the permission request metadata object (e.g., { pattern: "...", path: undefined, include: undefined }), leaving keys with undefined values that can cause schema encoding or serialization issues.

This PR fixes the issue by:

  1. Conditionally adding path and include to permission request metadata only when defined in GlobTool (packages/opencode/src/tool/glob.ts) and GrepTool (packages/opencode/src/tool/grep.ts).
  2. Filtering out any undefined metadata values in Permission.ask (packages/opencode/src/permission/index.ts) before building the permission request object.

How did you verify your code works?

Added unit tests to verify permission request metadata construction and schema encoding:

  • packages/opencode/test/permission/next.test.ts: Verified permission requests omit undefined metadata properties and encode properly with Schema.encode(Schema.Array(PermissionV1.Request)).
  • packages/opencode/test/tool/glob.test.ts: Verified GlobTool omits path key when not supplied and includes it when provided.
  • packages/opencode/test/tool/grep.test.ts: Verified GrepTool omits path and include keys when not supplied and includes them when provided.

Screenshots / recordings

N/A (No UI changes)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate Found

PR #37965: fix(core): omit undefined optional keys from glob/grep permission metadata

This PR appears to be directly related to your current PR #41671. Both address the same issue: omitting undefined optional keys from glob/grep permission metadata. This could indicate that:

  1. PR fix(core): omit undefined optional keys from glob/grep permission metadata #37965 may already address this issue in a different location (e.g., core vs opencode packages)
  2. It may be a duplicate that needs consolidation
  3. It may be a related but distinct fix in different parts of the codebase

Recommend checking PR #37965 to understand if it covers the same fixes or if they target different but related parts of the system.

@asiimhusain asiimhusain changed the title fix(opencode): omit undefined search metadata from permissions Fixes #37650 Aug 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hey! Your PR title Fixes #37650 doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@asiimhusain asiimhusain closed this by deleting the head repository Aug 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant