Fix 5047#5050
Conversation
Signed-off-by: Lukasz Gryglicki <lgryglicki@cncf.io> Assisted by [OpenAI](https://platform.openai.com/) Assisted by [GitHub Copilot](https://github.com/features/copilot)
WalkthroughReplaces name-only refresh with ChangesStored identity refresh and input validation improvements
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (1 warning, 2 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 `@cla-backend-go/cmd/server.go`:
- Around line 916-930: Normalize and trim claUser.LFEmail before comparing and
persisting: create a normalized variable (e.g., normalizedLF :=
strings.ToLower(strings.TrimSpace(claUser.LFEmail))) and use that for the
emailChanged check (compare against
strings.ToLower(strings.TrimSpace(string(userModel.LfEmail))) or use
strings.EqualFold on trimmed values) instead of raw claUser.LFEmail, and when
populating updates["lf_email"] assign the normalizedLF so stored emails have no
surrounding whitespace and are lowercased.
🪄 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: a5151411-70f8-4e7a-a7a7-7c0858593049
📒 Files selected for processing (6)
cla-backend-go/cmd/refresh_stored_username_test.gocla-backend-go/cmd/server.gocla-backend-go/company/repository.gocla-backend-go/emails/params.gocla-backend-go/events/service.gocla-backend-go/signatures/converters.go
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #5047 by syncing updated CLA Manager identity claims (notably primary email) back into EasyCLA’s cla-prod-users (lf_email) record during subsequent interactions with the backend, preventing notifications from continuing to target a stale email address.
Changes:
- Update
refreshStoredUserNameto also synclf_email(and add unit tests covering name/email change combinations). - Add defensive guards to avoid noisy warnings/errors or panics when legacy/edge-case data is missing (empty
signedOn, missing event user resolution, empty email template projects, emptycompanyID).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| cla-backend-go/signatures/converters.go | Avoid calling time formatting on empty legacy signature timestamps to prevent spurious warnings. |
| cla-backend-go/events/service.go | Skip event creation when UserID can’t be resolved from LfUsername, logging a warning instead. |
| cla-backend-go/emails/params.go | Prevent slice-out-of-range panics when email template params have no projects, returning safe defaults. |
| cla-backend-go/company/repository.go | Add an early guard for empty companyID before DynamoDB lookup. |
| cla-backend-go/cmd/server.go | Sync lf_email (and user_name) from auth claims into the stored user record on subsequent requests. |
| cla-backend-go/cmd/refresh_stored_username_test.go | Add tests for the updated refreshStoredUserName behavior across name/email change scenarios. |
Signed-off-by: Lukasz Gryglicki <lgryglicki@cncf.io> Assisted by [OpenAI](https://platform.openai.com/) Assisted by [GitHub Copilot](https://github.com/features/copilot)
Fixes #5047
Signed-off-by: Lukasz Gryglicki lgryglicki@cncf.io
Assisted by OpenAI
Assisted by GitHub Copilot
Assisted by Claude