feat(relay): expose user and group context to parameter override - #6534
feat(relay): expose user and group context to parameter override#6534seefs001 wants to merge 1 commit into
Conversation
Walkthrough
ChangesParam override context
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: Poem
🚥 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@relay/common/override.go`:
- Around line 2047-2049: Implement the documented token_group fallback in the
override publication logic around the TokenGroup and UserGroup fields: when
TokenGroup is empty, publish UserGroup instead; preserve an explicitly provided
TokenGroup unchanged. Add a regression test covering UserGroup set with an empty
TokenGroup and verify token_group-based overrides match.
🪄 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 Plus
Run ID: fc631ee9-b2df-4044-bae4-2af201977a3c
📒 Files selected for processing (2)
relay/common/override.gorelay/common/override_test.go
| // - user_group:用户所属分组。 | ||
| // - token_group:令牌指定的分组;未指定时回退为用户分组。 | ||
| // - using_group:当前实际使用的分组,自动跨分组重试时可能变化。 |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Implement the documented token_group fallback.
Line 2060 publishes an empty TokenGroup unchanged, contradicting Line 2048’s fallback-to-UserGroup contract. Overrides conditioned on token_group will not match for tokens without an explicit group.
Proposed fix
ctx["user_id"] = info.UserId
ctx["user_group"] = info.UserGroup
-ctx["token_group"] = info.TokenGroup
+tokenGroup := info.TokenGroup
+if tokenGroup == "" {
+ tokenGroup = info.UserGroup
+}
+ctx["token_group"] = tokenGroup
ctx["using_group"] = info.UsingGroupAdd a regression case with UserGroup set and TokenGroup empty.
Also applies to: 2058-2060
🤖 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 `@relay/common/override.go` around lines 2047 - 2049, Implement the documented
token_group fallback in the override publication logic around the TokenGroup and
UserGroup fields: when TokenGroup is empty, publish UserGroup instead; preserve
an explicitly provided TokenGroup unchanged. Add a regression test covering
UserGroup set with an empty TokenGroup and verify token_group-based overrides
match.
Important
📝 变更描述 / Description
(简述:做了什么?为什么这样改能生效?请基于你对代码逻辑的理解来写,避免粘贴未经整理的内容)
🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。📸 运行证明 / Proof of Work
(请在此粘贴截图、关键日志或测试报告,以证明变更生效)
Summary by CodeRabbit
New Features
Tests