Skip to content

fix(core): reject invalid opaque tools at registration - #49573

Open
cestercian wants to merge 1 commit into
anomalyco:devfrom
cestercian:tool-register-validate
Open

cestercian wants to merge 1 commit into
anomalyco:devfrom
cestercian:tool-register-validate

Conversation

@cestercian

@cestercian cestercian commented Sep 17, 2026

Copy link
Copy Markdown

Issue for this PR

Fixes #35963

Type of change

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

What does this PR do?

Invalid opaque Tool values (for example a tool created by a different loaded copy of @opencode-ai/plugin) were accepted by ToolRegistry.register / ApplicationTools.register and only blew up later while materializing the Location tool catalog.

This PR calls Tool.validate on every entry before mutating registrations. A bad tool fails with RegistrationError and the previous catalog is left unchanged.

This is the register-time validation slice called out in #35963. Broader atomic plugin reload is still out of scope.

How did you verify your code works?

  • bun test test/session-runner-tool-registry.test.ts test/application-tools.test.ts (31 pass)
  • bun typecheck in packages/core
  • Added regression tests that register a healthy tool, then attempt a batch containing a structuredCloned opaque tool, assert RegistrationError, and confirm the healthy tool remains registered/executable

Screenshots / recordings

N/A — core registry behavior, no UI change.

Checklist

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

Validate WeakMap ownership in Tool.validate before ToolRegistry and
ApplicationTools mutate registrations so a cloned or foreign tool fails
with RegistrationError and leaves healthy tools materializable.
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Sep 17, 2026
@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 github-actions Bot removed needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels Sep 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

fix(core): isolate invalid plugin tools during reload

1 participant