fix(providers): gate OpenCode Go quota on the canonical base URL - #2027
fix(providers): gate OpenCode Go quota on the canonical base URL#2027yzxcj797 wants to merge 12 commits into
Conversation
Promote dev to main: Wave 5 campaign (107 commits)
Promote dev to main: CodeQL lidge-jun#87 ReDoS fix + closeout correction
Promote dev to main: Wave 5 record corrections
Promote dev to main: alert-precision record
Promote dev to main: post-scan closing note
Promote dev to main: final Wave 5 errata
Promote dev to main: Wave 5 closing record
[WRONG BRANCH] Promote dev to main: v2.25.0 release
release: v2.25.0
The quota probe required the provider to be literally named opencode-go, so multi-account setups pointing sibling providers at the canonical https://opencode.ai/zen/go/v1 base URL showed no rate-limit panel and produced no report rows (lidge-jun#1924). The Kimmi/A6api/CommandCode branches already gate on their canonical base URLs, and fetchOpenCodeGoQuota re-validates the canonical URL before sending the bearer key, so the name check was both too narrow and redundant. Gate on isCanonicalOpenCodeGoBaseUrl(provider.baseUrl) instead. Regression tests cover the sibling-provider repro and that a non-canonical base URL never probes opencode.ai.
|
✅ Deterministic PR hygiene checks passed. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan includes up to 10 reviews per rolling hour; 9 remain after this review. 📝 WalkthroughWalkthroughOpenCode Go quota probing now targets every key-auth provider using the canonical base URL. Tests cover multiple provider names on that URL and exclude providers using other base URLs. ChangesOpenCode Go quota probing
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The change enables quota reporting for sibling providers using the canonical OpenCode Go URL while avoiding probes from non-canonical hosts. No actionable merge-blocking risk remains beyond normal checks and review. Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 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 |
⏳ DRAFT
What to do
Review readiness checklist
0/4 boxes ticked. This pull request was already a draft. Its draft status will be preserved after every issue above is resolved. |
|
Retargeted this draft from release-only The reported defect is real on current Please rebase the branch onto current |
리뷰 · 우선순위 27 / 80draft 이고 readiness 4칸이 비어 있습니다. #1924 는 quota 디스패치가
canonical URL 을 가리키는 모든 key-auth 제공자가 Go usage 엔드포인트를 칩니다. 구독이 아닌 호스트 재사용이면 불필요한 프로브가 생깁니다. 이웃 프로바이더와 같은 트레이드오프입니다. 해결방안: 이 댓글은 grok-bot이 작성했습니다 |
|
Thank you @yzxcj797 — absorbed as #2164, and the diagnosis is yours. Gating quota dispatch on the literal name One correction. Your predicate compares the base URL but does not check the adapter, so a row pointed at The repository already has the predicate for this: Worth recording what was considered and rejected: Your branch was marked Your sibling-row test is carried over and it fails on unpatched |
…amed A multi-account setup points several provider rows at the same OpenCode Go endpoint under names the registry has never heard of -- opencode-go-2 through -5. Quota dispatch gated on the literal name "opencode-go", so those rows had no dashboard quota panel and no report in `ocx provider quota --refresh --json` even though each one holds a working key for the same upstream (lidge-jun#1924). Identity is now answered by registryEntryForProviderDestination, the predicate this repository already uses for renamed fixed-key rows: it matches on normalized endpoint plus adapter plus key auth. A bare URL comparison would have been enough for the reported symptom but would also probe a row that points at that host through a different adapter, which speaks a different protocol and is not the provider whose quota shape we parse. The defensive canonical-URL check inside fetchOpenCodeGoQuota stays. Whether an API key may be sent to a host must not depend on the dispatch gate above it being correct. Absorbed from lidge-jun#2027 by @yzxcj797.
…amed A multi-account setup points several provider rows at the same OpenCode Go endpoint under names the registry has never heard of -- opencode-go-2 through -5. Quota dispatch gated on the literal name "opencode-go", so those rows had no dashboard quota panel and no report in `ocx provider quota --refresh --json` even though each one holds a working key for the same upstream (lidge-jun#1924). Identity is now answered by registryEntryForProviderDestination, the predicate this repository already uses for renamed fixed-key rows: it matches on normalized endpoint plus adapter plus key auth. A bare URL comparison would have been enough for the reported symptom but would also probe a row that points at that host through a different adapter, which speaks a different protocol and is not the provider whose quota shape we parse. The defensive canonical-URL check inside fetchOpenCodeGoQuota stays. Whether an API key may be sent to a host must not depend on the dispatch gate above it being correct. Absorbed from lidge-jun#2027 by @yzxcj797.
Summary
Fixes #1924.
Root cause (as reported)
The OpenCode Go quota probe gated on the provider's name:
so in multi-account setups — sibling providers pointing at the canonical
https://opencode.ai/zen/go/v1for subscription balancing — only the provider literally namedopencode-goproduced quota rows; the dashboard showed no rate-limit panel for the siblings. The neighboring branches (Kimi, A6api, CommandCode) already gate on their canonical base URLs, andfetchOpenCodeGoQuotaitself re-validatesisCanonicalOpenCodeGoBaseUrl(config.baseUrl)before sending the bearer key, making the name check both too narrow and redundant.Fix
Safe against key leakage to non-canonical hosts: the fetch still re-validates the canonical URL before the bearer key leaves.
Tests
Two regression tests in
tests/opencode-go-quota.test.ts:opencode-go-2on the canonical base URL now reports quota alongsideopencode-go(both rows present, both fetches made) — onmainthis yields only one row;opencode-goon a non-canonical base URL never probesopencode.aiwith the key.(Couldn't run the bun test suite locally on this Windows checkout; relying on CI.)
Review readiness checklist
This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:
All CI tests are green on my local testing.
I pushed my PR to the latest dev commit.
I resolved all correct Codex and CodeRabbit findings.
My PR is ready for review.
Summary by CodeRabbit
Bug Fixes
Tests