Skip to content

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

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

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.

(Supersedes #44375, which was auto-closed before its description could be brought up to the PR template.)

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

Copy link
Copy Markdown
Contributor

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

I found two potentially related PRs that address similar permission metadata issues:

  1. 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

    • Directly addresses the same problem area (glob/grep permission metadata with absent optional fields)
  2. fix(opencode): drop undefined from v1 permission metadata #38918 - fix(opencode): drop undefined from v1 permission metadata

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

These PRs appear to address similar or overlapping issues with undefined values in permission metadata. You may want to check if #40852 is still open or if it was previously closed, since the PR description mentions that #44375 was auto-closed before the template could be completed.

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