fix(core): omit undefined optional keys from glob/grep permission metadata - #37965
IbrahimKhan12 wants to merge 1 commit into
Conversation
|
The following comment was made by an LLM, it may be inaccurate: Potential Related PR Found:
Why they're related: |
…adata
The glob and grep tools built their permission metadata by assigning
input.path/input.limit/input.include directly. When those optional
inputs are omitted, the decoded input has no such key, so reading it
yields undefined and materializes undefined-valued keys in the metadata
bag (e.g. { root: ".", path: undefined, limit: undefined }).
Permission metadata is Schema.Record(String, Unknown) and is serialized
as JSON for session.permission.list. The undefined entries survive
schema encoding as own properties and break strict JSON encoding of the
response, so a single pending glob/grep permission with omitted optional
inputs can make the whole listing fail.
Only include the optional keys when their value is defined, matching the
webfetch/websearch tools which spread the exact-optional decoded input
and never introduce undefined keys.
Refs anomalyco#37650
9bb6dae to
7be147b
Compare
|
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:
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. |
Issue for this PR
Fixes #37650
Type of change
What does this PR do?
globandgrepcopied omitted optional inputs into pending permission metadata as explicitundefinedvalues. Permission metadata must be JSON, sosession.permission.listcould fail schema encoding while one of those requests was waiting for approval.This change conditionally includes
path,include, andlimitonly when callers provide them. The required metadata remains unchanged, and supplied optional values are still preserved for permission display and persistence.How did you verify your code works?
bun test test/tool-glob.test.ts test/tool-grep.test.tsfrompackages/core: 4 tests pass. The tests execute the real tools and verify both omitted and supplied optional metadata fields.bun typecheckfrompackages/core: passes.Screenshots / recordings
N/A, this changes permission metadata encoding only.
Checklist