Skip to content

fix(core): omit absent optional fields from glob and grep permission metadata - #40852

Closed
vextalor-dev wants to merge 1 commit into
anomalyco:devfrom
vextalor-dev:glob-grep-metadata
Closed

fix(core): omit absent optional fields from glob and grep permission metadata#40852
vextalor-dev wants to merge 1 commit into
anomalyco:devfrom
vextalor-dev:glob-grep-metadata

Conversation

@vextalor-dev

Copy link
Copy Markdown

Issue for this PR

Fixes #37650

Type of change

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

What does this PR do?

Pending glob and grep permission requests could carry explicit undefined values in their metadata when the model omitted optional inputs (path, include, limit). JSON encoding of that metadata fails ("Expected JSON value, got undefined"), which made session.permission.list reject its response body and hide pending permission prompts.

The metadata is now built with only the keys that have a defined value. root stays constant (. or the provided path), and absent optional fields are omitted entirely. Verified with a new regression test that executes both tools with and without the optional fields, and asserts the recorded permission metadata contains no undefined values and survives a JSON round-trip.

How did you verify your code works?

  • bun test test/tool-glob-grep.test.ts in packages/core: 2 pass (test fails when the fix is reverted)
  • bun test test/permission.test.ts test/ripgrep.test.ts: 15 pass
  • bun typecheck in packages/core: clean
  • oxlint on the touched files: 0 warnings, 0 errors

Screenshots / recordings

If this is a UI change, please include a screenshot or recording.

Checklist

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

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

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

Potential Duplicate PRs Found:

  1. PR fix(core): drop undefined metadata values from permission requests #37679 - fix(core): drop undefined metadata values from permission requests

    • Addresses the same core issue of removing undefined values from permission metadata
  2. PR fix(core): omit undefined optional keys from glob/grep permission metadata #37965 - fix(core): omit undefined optional keys from glob/grep permission metadata

    • Almost identical to the current PR - specifically targets glob/grep optional fields like path, include, limit
  3. PR fix(opencode): drop undefined from v1 permission metadata #38918 - fix(opencode): drop undefined from v1 permission metadata

    • Related fix for removing undefined from permission metadata in a different context

Recommendation: PRs #37965 and #37679 appear to be very closely related or potentially duplicate efforts addressing the same issue (#37650). You should review #37965 in particular, as it has the nearly identical title and scope to PR #40852.

@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

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:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

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.

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.

tools: optional search metadata breaks pending permission listing

1 participant