fix(plugin): skip mismatched kind in readV1Plugin detect mode - #40426
Open
Thatgfsj wants to merge 1 commit into
Open
fix(plugin): skip mismatched kind in readV1Plugin detect mode#40426Thatgfsj wants to merge 1 commit into
Thatgfsj wants to merge 1 commit into
Conversation
When the server plugin loader scans modules with mode="detect", a plugin that exports only `tui` (and no `server`) currently falls through to the kind-specific check and throws a misleading "must default export an object with server()" error. The error is caught and logged, polluting startup logs for legitimate TUI-only plugins. Mirror the existing all-fields-missing guard with per-kind short-circuits so detect mode silently skips plugins that don't expose the requested kind's entrypoint. Adds a regression test covering TUI-only and server-only detection. Fixes anomalyco#31610
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #31610
Type of change
What does this PR do?
In
readV1Plugin(packages/opencode/src/plugin/shared.ts), when theserver plugin loader calls it with
mode="detect"andkind="server",a plugin module that exports only
tuifalls through to thekind-specific check and throws
TypeError: Plugin ... must default export an object with server(). The error is caught and logged atERROR level on every startup for users with TUI-only plugins, which
is noisy and misleading.
The existing "all fields missing" guard does not fire because
idand
tuiare present. The fix mirrors that guard with two newper-kind short-circuits so detect mode silently skips plugins that
don't expose the requested kind's entrypoint. The mirror for
kind === "tui"is included for symmetry even though the bug reportonly mentioned the server path.
Strict mode is unchanged: a TUI-only plugin supplied as a server
plugin under strict mode still throws, which is the desired behavior.
How did you verify your code works?
Added a regression test (
test/plugin/read-v1-plugin.test.ts) withfour cases:
bun test packages/opencode/test/plugin/read-v1-plugin.test.ts-> 4/4 pass.Screenshots / recordings
Not applicable (no UI change).
Checklist