Skip to content

fix(opencode): skip falsy plugin hook returns instead of crashing provider listing#13

Merged
CreatorGhost merged 1 commit into
devfrom
plugin-hook-guard
Jul 12, 2026
Merged

fix(opencode): skip falsy plugin hook returns instead of crashing provider listing#13
CreatorGhost merged 1 commit into
devfrom
plugin-hook-guard

Conversation

@CreatorGhost

@CreatorGhost CreatorGhost commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Port of upstream anomalyco/opencode#36102.

Plugin hook collection now guards against plugins that return undefined/falsy hook objects — previously these were pushed into the hook list and crashed provider listing with a 500.

Verified: bun test test/plugin/ (166 pass across 16 files, includes new falsy-hooks regression suite) and bun typecheck from packages/opencode. Applied cleanly.

Summary by CodeRabbit

  • Bug Fixes

    • Improved plugin loading to detect and warn when plugins or plugin exports provide no hooks.
    • Prevented empty or invalid hook entries from being loaded, improving plugin reliability.
    • Preserved valid hooks when other plugin exports are empty or unsupported.
  • Tests

    • Added coverage for legacy and current plugin formats with missing hook implementations.

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fbd40466-51ee-4a27-af2e-b83f73824082

📥 Commits

Reviewing files that changed from the base of the PR and between f862420 and bd61dbf.

📒 Files selected for processing (2)
  • packages/opencode/src/plugin/index.ts
  • packages/opencode/test/plugin/falsy-hooks.test.ts

📝 Walkthrough

Walkthrough

Plugin loading now filters falsy hook results, records plugin modules that produce no hooks, and logs warnings for internal and external no-hook cases. New tests cover legacy helper exports and v1 server functions resolving to undefined.

Changes

Plugin hook filtering

Layer / File(s) Summary
No-hook handling and validation
packages/opencode/src/plugin/index.ts, packages/opencode/test/plugin/falsy-hooks.test.ts
applyPlugin tracks skipped plugins, loader paths warn when no hooks are returned, and tests verify falsy hooks are excluded for legacy and v1 plugins.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main fix: skipping falsy plugin hook returns to prevent provider listing crashes.
Description check ✅ Passed The description covers the issue, fix, and verification, but it omits the template sections for type, checklist, and issue reference.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch plugin-hook-guard

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@CreatorGhost

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@CreatorGhost

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@CreatorGhost CreatorGhost merged commit 1652558 into dev Jul 12, 2026
5 of 7 checks passed
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.

1 participant