Skip to content

Skip v2 setup when the host has no provider API - #39

Open
uriahcarpenter wants to merge 1 commit into
yuseferi:mainfrom
uriahcarpenter:fix/skip-v2-setup-without-provider-api
Open

uriahcarpenter wants to merge 1 commit into
yuseferi:mainfrom
uriahcarpenter:fix/skip-v2-setup-without-provider-api

Conversation

@uriahcarpenter

@uriahcarpenter uriahcarpenter commented Oct 5, 2026 •

Copy link
Copy Markdown

Summary

On OpenCode 1.18.34, starting the TUI with this plugin with version v1.4.0+ prints

[opencode-litellm] Could not read configured providers: undefined is not an object (evaluating 'context.provider.list')
No LiteLLM proxy found. Configure providers.litellm.settings.baseURL or start LiteLLM on port 4000/8000/8080.

This PR makes setup return early when the host has no provider API, so the plugin operates in OpenCode 1.18.34.

Cause

The default export carries both the OpenCode 2 setup and the OpenCode 1 server() entrypoints. OpenCode 1.18.x ships an in-tree v2 plugin host (packages/core/src/config/plugin/external.ts) that calls setup on any plugin whose default export has id and setup. That host's context exposes catalog, not provider, so:

  1. context.provider.list() throws and is caught and logged (first message).
  2. Auto-detection finds nothing and logs the second message.
  3. context.provider.transform throws and the host swallows the error.

The logs also reach the terminal because setup calls initV2Logging(), which clears the client-backed logger that server() installed, so logInfo falls back to console.log.

Change

setup now returns before doing anything when context.provider is missing. Those hosts are served by server(). The check sits before initV2Logging() so the V1 logger is left intact.

I did not gate on the host version: the missing provider domain is the exact condition setup cannot work without, and it keeps working if later hosts add it.

Type of change

  • 🐛 Bug fix (non-breaking)

Checklist

  • npm run typecheck passes
  • No new runtime dependencies
  • README updated if public API or behavior changed (no change needed)
  • CHANGELOG.md updated under ## [Unreleased] (the file has no Unreleased section; it is generated by semantic-release)
  • Commit messages follow Conventional Commits

How was this tested?

New unit test does nothing when the host context has no provider API passes a context with only catalog and asserts that setup resolves without logging or fetching. It failed before the change with Cannot 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

  • Bug Fixes
    • Plugin setup now handles hosts without a provider API, allowing them to continue through the existing server entry point without logging or fetching provider data.

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.
@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

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
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 38030398-13f7-4969-822f-45402012da86
📥 Commits

Reviewing files that changed from the base of the PR and between 72407ea and 3bce232.

📒 Files selected for processing (2)
  • src/plugin/v2.ts
  • test/plugin-v2.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The 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.

Changes

Provider Availability Guard

Layer / File(s) Summary
Guard plugin setup when provider is absent
src/plugin/v2.ts, test/plugin-v2.test.ts
Setup returns when context.provider is unavailable. The test checks that setup returns undefined and makes no logging or fetch calls.

Priority: ➖ Normal

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix

Suggested reviewers: alexanderwillner

Merge Risk: ⚪ Minimal · up to 3bce2

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 Summary

Architecture risk: 🔵 Low · up to 3bce2

The change affects 2 systems.

Changed systems: src, test

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — src (service) was modified; 1 changed file maps to changed impact.
  • observed — test (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in src/plugin/v2.ts: setup now exits when context.provider is absent; previously it continued into v2 logging and provider setup.
  • observed — Modified behavior in test/plugin-v2.test.ts: Adds a test for setup with a context exposing catalog but no provider API. It asserts setup returns no cleanup function and makes neither console-log nor network-fetch calls.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: skipping v2 setup when the host has no provider API.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

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