Repository navigation
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (5)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. WalkthroughSubscription billing now carries the relay group into quota pre-consumption and wallet-overflow checks. Group-aware selection trims request groups, skips mismatched subscription plans, and preserves empty-group compatibility. Tests verify selection and database isolation. ChangesSubscription group scoping
Estimated code review effort: 3 (Moderate) | ~25 minutes Merge Risk: ⚪ Minimal · up to The change limits subscription pre-consumption to matching request groups while preserving compatibility for plans without an upgrade group; no actionable merge-blocking risk remains after normal checks and review. Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Linked Issues checkExplanation The changes satisfy issue
✨ 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
model/subscription_group_test.go (1)
48-63: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a backward-compatibility test for empty
UpgradeGroup.The current test validates the skip behavior for mismatched groups. A plan with an empty
UpgradeGroupshould remain usable for anyrequestGroup— this is the core backward-compatibility guarantee stated in the PR objectives. Adding a test protects this invariant against future regressions.♻️ Suggested additional test
+func TestPreConsumeUserSubscriptionForGroupEmptyUpgradeGroupBackwardCompat(t *testing.T) { + truncateTables(t) + + const userID = 6101 + seedGroupPlan(t, 6101, "") // empty UpgradeGroup — should match any group + seedGroupSubscription(t, 6101, userID, 6101, 0) + + res, err := PreConsumeUserSubscriptionForGroup("req-group-any", userID, "deepseek-v4", "some-other-group", 0, 300) + require.NoError(t, err) + + assert.Equal(t, 6101, res.UserSubscriptionId) + assert.EqualValues(t, 300, groupSubscriptionUsed(t, 6101)) +}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@model/subscription_group_test.go` around lines 48 - 63, Add a test alongside TestPreConsumeUserSubscriptionForGroupSkipsMismatchedPlanGroup that seeds a subscription whose plan has an empty UpgradeGroup, invokes PreConsumeUserSubscriptionForGroup with a non-empty requestGroup, and asserts the empty-group subscription is selected and its usage increases while mismatched candidates remain unused.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@service/billing_session.go`:
- Line 390: Update UserActiveSubscriptionsAllowWalletOverflow to filter active
subscriptions by requestGroup before evaluating allow_wallet_overflow; only
subscriptions matching the request’s group should be able to block wallet
fallback. Ensure the caller passes the relayInfo.UsingGroup value through the
request-group parameter and preserve existing behavior for matching
subscriptions.
---
Nitpick comments:
In `@model/subscription_group_test.go`:
- Around line 48-63: Add a test alongside
TestPreConsumeUserSubscriptionForGroupSkipsMismatchedPlanGroup that seeds a
subscription whose plan has an empty UpgradeGroup, invokes
PreConsumeUserSubscriptionForGroup with a non-empty requestGroup, and asserts
the empty-group subscription is selected and its usage increases while
mismatched candidates remain unused.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f79d87d5-d5fc-4c4c-a111-6e4deb786480
📒 Files selected for processing (5)
model/subscription.gomodel/subscription_group_test.gomodel/task_cas_test.goservice/billing_session.goservice/funding_source.go
|
Addressed CodeRabbit feedback:
Pushed in |
3 similar comments
|
Addressed CodeRabbit feedback:
Pushed in |
|
Addressed CodeRabbit feedback:
Pushed in |
|
Addressed CodeRabbit feedback:
Pushed in |
|
@Calcium-Ion @t0ng7u 麻烦有空时 review 一下这个 PR。 范围:仅 #5200 — 订阅预扣按请求 group 隔离;CodeRabbit 反馈(wallet overflow 需 group-aware、empty UpgradeGroup 兼容测试)已在后续 commit 修完。谢谢。 |
|
Rebased onto latest Conflict was only in Local verification:
|
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
|
已 rebase 到最新 新 head 上 CI 全绿: 范围未变,仍只是 #5200:按请求分组隔离订阅预扣。 @Calcium-Ion @seefs001 与 #6089 相邻,建议一并 review。 |
Important
📝 变更描述 / Description
订阅预扣现在会校验请求实际使用的 group。带 upgrade_group 的订阅计划只覆盖同分组请求,避免跨分组模型错误扣订阅额度。billing session 会把 relayInfo.UsingGroup 传入预扣路径;UpgradeGroup 为空的计划保持原有兼容行为。
This PR was AI-assisted and manually reviewed before submission.
🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。📸 运行证明 / Proof of Work
Summary by CodeRabbit