-
Notifications
You must be signed in to change notification settings - Fork 46
Bug RHOAIENG-39110: Fix username display to remove cluster suffix #532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Bug RHOAIENG-39110: Fix username display to remove cluster suffix #532
Conversation
Fix username display in top-right to show clean username instead of user@cluster.local format. The X-Forwarded-Preferred-Username header contains cluster suffixes that should be stripped for display purposes. Changes: - Modified /app/api/me/route.ts to strip everything after @ symbol from displayName while preserving original username field - Handles edge cases: no @ symbol, multiple @ symbols, email addresses - Maintains backward compatibility Example: "gkrumbac@cluster.local" now displays as "gkrumbac" Fixes: https://issues.redhat.com/browse/RHOAIENG-39110 Co-Authored-By: Claude (claude-sonnet-4-5) <noreply@anthropic.com>
Claude Code ReviewSummaryThis PR fixes the username display in the top-right corner by stripping cluster domain suffixes (e.g., Issues by Severity🚫 Blocker IssuesNone found. 🔴 Critical IssuesNone found. 🟡 Major IssuesNone found. 🔵 Minor Issues1. Missing Test Coverage
2. Potential Ambiguity with Email Addresses
3. TypeScript Type Safety
Positive Highlights✅ Minimal, focused change - Only 5 additions, 1 deletion. Perfect example of targeted bug fix. ✅ Preserves original fields - The ✅ Handles edge cases - Uses optional chaining ( ✅ Clear intent - Code comment explains what the transformation does. ✅ Follows React Query patterns - The API endpoint is consumed via React Query hooks ( ✅ Correct usage in UI - The ✅ No security concerns - The transformation is purely cosmetic and doesn't affect authentication or authorization logic. ✅ CI passing - All automated checks are passing. RecommendationsPriority 1: Add Unit TestsCreate import { GET } from './route';
describe('/api/me route', () => {
it('should strip cluster suffix from username', async () => {
const request = new Request('http://localhost:3000/api/me', {
headers: {
'X-Forwarded-Preferred-Username': 'gkrumbac@cluster.local',
},
});
const response = await GET(request);
const data = await response.json();
expect(data.displayName).toBe('gkrumbac');
expect(data.username).toBe('gkrumbac@cluster.local'); // Original preserved
});
it('should handle username without @ symbol', async () => {
const request = new Request('http://localhost:3000/api/me', {
headers: {
'X-Forwarded-Preferred-Username': 'username',
},
});
const response = await GET(request);
const data = await response.json();
expect(data.displayName).toBe('username');
});
// Add more test cases...
});Priority 2: Enhance Code CommentUpdate the comment to be more explicit about email handling: // Clean the displayName by removing cluster suffix (e.g., "@cluster.local", "@apps-crc.testing")
// Note: This also strips email domains when email is used as fallback (user@company.com → user)
const rawDisplayName = username || email || userId;
const displayName = rawDisplayName?.split('@')[0] || rawDisplayName;Priority 3: Consider E2E TestAdd a Cypress test in it('should display cleaned username in top-right corner', () => {
cy.visit('/');
cy.get('[data-testid="user-bubble"]').should('contain', 'gkrumbac');
cy.get('[data-testid="user-bubble"]').should('not.contain', '@cluster.local');
});Architecture & Standards Compliance✅ Frontend patterns: Follows React Query usage patterns from ✅ Type definitions: Uses proper TypeScript types ( ✅ Shadcn UI: The ✅ No ✅ API client layer: Properly separates API logic ( Final VerdictAPPROVE ✅ This is a well-crafted, focused bug fix that solves the reported issue cleanly. The code is safe, follows project patterns, and has no security or architectural concerns. The only improvement needed is test coverage, which should be added in a follow-up PR or before merge if time permits. Suggested next steps:
Great work on keeping this change minimal and focused! 🎉 🔍 View AI decision process (logs available for 90 days) 📋 View memory system files loaded (click to expand)What Amber Loaded for Code ReviewAmber automatically loaded these repository standards from the memory system:
Impact: This review used your repository's specific code quality standards, security patterns, and best practices from the memory system (PRs #359, #360) - not just generic code review guidelines. |
Summary
Fixes username display in the top-right corner to show clean username instead of
user@cluster.localformat.Problem
The
X-Forwarded-Preferred-Usernameheader contains values likegkrumbac@cluster.local, and the frontend API endpoint was using this value directly fordisplayName, causing the UI to showgkrumbac@cluster.localinstead of justgkrumbac.Solution
Modified
components/frontend/src/app/api/me/route.tsto strip everything after the@symbol from the displayName while preserving the original username field unchanged.Changes
@and take the first part@symbol (passthrough)@symbols (takes first part)Testing
The fix handles all expected scenarios:
gkrumbac@cluster.local→ displays asgkrumbac✓user@apps-crc.testing→ displays asuser✓username→ displays asusername✓Related Issue
Fixes: https://issues.redhat.com/browse/RHOAIENG-39110