Skip to content

fix(core): keep glob/grep permission metadata JSON-encodable - #44375

Closed
Enough1122 wants to merge 1 commit into
anomalyco:devfrom
Enough1122:fix/grep-glob-permission-metadata
Closed

Enough1122 wants to merge 1 commit into
anomalyco:devfrom
Enough1122:fix/grep-glob-permission-metadata

Conversation

@Enough1122

@Enough1122 Enough1122 commented Aug 23, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #37650

Type of change

  • Bug fix

What does this PR do?

Pending glob and grep permissions store absent optional tool inputs (path, include, limit) as undefined inside JSON permission metadata, so when session.permission.list encodes its response, schema validation fails with Expected JSON value, got undefined.

This adds a small jsonMetadata helper in packages/core/src/tool/metadata.ts that omits undefined fields, and builds the glob/grep permission metadata through it: absent optional inputs are simply left out of the record, so permission listing stays schema-valid whether or not the model supplied them.

How did you verify your code works?

  • New unit tests in packages/core/test/tool-permission-metadata.test.ts cover the all-optional-absent case from the issue, the fully-populated case, and the mixed path-only case: 3 pass.
  • Existing related suites still pass: tool-bash, tool-edit, filesystem/search → 22 pass.
  • bun run typecheck clean in @opencode-ai/core and across the monorepo.

Screenshots / recordings

Not a UI change.

Checklist

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

Pending glob and grep permissions stored absent optional tool inputs
(path/include/limit) as undefined inside JSON permission metadata, which
made session.permission.list reject its own response body with
'Expected JSON value, got undefined'.

Build the metadata through a small jsonMetadata helper that omits
undefined fields, so permission listing stays schema-valid whether or
not optional search inputs are supplied.

Fixes anomalyco#37650
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Aug 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions

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): omit absent optional fields from glob and grep permission metadata #40852: "fix(core): omit absent optional fields from glob and grep permission metadata"

  2. PR fix(opencode): drop undefined from v1 permission metadata #38918: "fix(opencode): drop undefined from v1 permission metadata"

Why they're related: Both PR #40852 and the current PR #44375 target the same core problem: preventing undefined values in glob/grep permission metadata JSON encoding to satisfy schema validation. You should review whether #40852 was already merged and if so, whether the current PR is redundant.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Aug 23, 2026
@github-actions github-actions Bot closed this Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tools: optional search metadata breaks pending permission listing

1 participant