fix(controlplane): populate userEmail in whoAmI response#2774
Conversation
The whoAmI response schema includes an optional userEmail field, but the handler never populated it. Set it from the authenticated user's display name (which is the email) so clients can surface the current user's email without a separate lookup. ENG-9393
WalkthroughThe Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@controlplane/src/core/bufservices/organization/whoAmI.ts`:
- Line 41: The response currently populates the userEmail field from
authContext.userDisplayName; change this to source the actual email
claim/property (e.g., authContext.userEmail or authContext.claims.email) when
building the whoAmI response and do not fall back to userDisplayName; if no
email claim exists, omit or set userEmail to undefined/null instead of using the
display name. Locate the assignment for userEmail in whoAmI.ts (the line that
currently uses authContext.userDisplayName) and replace it with a check that
reads the explicit email claim/property and only sets userEmail when that claim
is present.
🪄 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: 395d0b77-a9b6-4e78-90b7-cde28c16d404
📒 Files selected for processing (1)
controlplane/src/core/bufservices/organization/whoAmI.ts
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2774 +/- ##
===========================================
+ Coverage 35.50% 64.45% +28.94%
===========================================
Files 129 311 +182
Lines 11789 44295 +32506
Branches 467 4764 +4297
===========================================
+ Hits 4186 28551 +24365
- Misses 7601 15721 +8120
- Partials 2 23 +21
🚀 New features to boost your workflow:
|
…ng-useremail-field
Summary by CodeRabbit
Populates the
userEmailfield in thewhoAmIresponse using the authenticated user's display name (which is the email). The proto schema already declared this as an optional field, but the handler was never setting it, so clients had no way to read the current user's email from this endpoint.Closes ENG-9393.
Checklist
Open Source AI Manifesto
This project follows the principles of the Open Source AI Manifesto. Please ensure your contribution aligns with its principles.