Skip v2 setup when the host has no provider API - #39
uriahcarpenter wants to merge 1 commit into
Conversation
OpenCode 1.18.x embeds a v2 plugin host that calls `setup` on any plugin exporting one, but its context exposes `catalog` instead of `provider`. `setup` then logged "Could not read configured providers" and "No LiteLLM proxy found" to the terminal and threw at `context.provider.transform`. Those versions are served by `server()`, so `setup` now returns early, before `initV2Logging()` replaces the client-backed logger that `server()` installed.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe v2 plugin setup now returns when the provider API is unavailable. A test checks the return value and confirms that setup does not log or fetch in that case. ChangesProvider Availability Guard
Priority: ➖ Normal Estimated code review effort: 1 (Trivial) | ~5 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to The change skips v2 setup when the provider API is absent while keeping the documented server entry point available. No merge-blocking risk is established. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 2 systems. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Summary
On OpenCode 1.18.34, starting the TUI with this plugin with version
v1.4.0+printsThis PR makes
setupreturn early when the host has noproviderAPI, so the plugin operates in OpenCode 1.18.34.Cause
The default export carries both the OpenCode 2
setupand the OpenCode 1server()entrypoints. OpenCode 1.18.x ships an in-tree v2 plugin host (packages/core/src/config/plugin/external.ts) that callssetupon any plugin whose default export hasidandsetup. That host's context exposescatalog, notprovider, so:context.provider.list()throws and is caught and logged (first message).context.provider.transformthrows and the host swallows the error.The logs also reach the terminal because
setupcallsinitV2Logging(), which clears the client-backed logger thatserver()installed, sologInfofalls back toconsole.log.Change
setupnow returns before doing anything whencontext.provideris missing. Those hosts are served byserver(). The check sits beforeinitV2Logging()so the V1 logger is left intact.I did not gate on the host version: the missing
providerdomain is the exact conditionsetupcannot work without, and it keeps working if later hosts add it.Type of change
Checklist
npm run typecheckpassesCHANGELOG.mdupdated under## [Unreleased](the file has no Unreleased section; it is generated by semantic-release)How was this tested?
New unit test
does nothing when the host context has no provider APIpasses a context with onlycatalogand asserts thatsetupresolves without logging or fetching. It failed before the change withCannot read properties of undefined (reading 'transform'). The full suite (111 tests) passes. I also ran the patched plugin in OpenCode 1.18.34 after deleting the model cache (~/.cache/opencode-litellm/models-*.json), and the startup messages no longer appear.Summary by CodeRabbit