Skip to content

Unicron downcase user emails#5097

Merged
lukaszgryglicki merged 11 commits into
devfrom
unicron-downcase-user-emails
Jun 25, 2026
Merged

Unicron downcase user emails#5097
lukaszgryglicki merged 11 commits into
devfrom
unicron-downcase-user-emails

Conversation

@lukaszgryglicki

Copy link
Copy Markdown
Member

Signed-off-by: Lukasz Gryglicki lgryglicki@cncf.io

Assisted by OpenAI

Assisted by GitHub Copilot

Assisted by Claude

Add sanction screening service prod
Signed-off-by: Lukasz Gryglicki <lgryglicki@cncf.io>

Assisted by [OpenAI](https://platform.openai.com/)

Assisted by [GitHub Copilot](https://github.com/features/copilot)

Assisted by [Claude](https://claude.ai)
Signed-off-by: Lukasz Gryglicki <lgryglicki@cncf.io>

Assisted by [OpenAI](https://platform.openai.com/)

Assisted by [GitHub Copilot](https://github.com/features/copilot)

Assisted by [Claude](https://claude.ai)
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

The PR normalizes email strings before storing or querying user_emails across users, approval requests, and legacy handlers. It also adds a script to scan existing DynamoDB users, lower-case and de-duplicate user_emails, and optionally write the updated sets back.

Changes

CLA email normalization

Layer / File(s) Summary
User repository storage and lookup
cla-backend-go/users/repository.go
CreateUser, Save, GetUsersByEmail, and normalizeEmails now trim, lowercase, drop empties, and deduplicate user_emails values before DynamoDB writes and lookups.
Allowlist request writes and removal lookup
cla-backend-go/approval_list/repository.go, cla-backend-legacy/internal/api/handlers.go, cla-backend-go/signatures/repository.go
CCLA request records and removed-email approvals now normalize email strings before storing user_emails or searching for users.
DynamoDB email backfill script
utils/downcase_emails.sh
A new shell script scans users with user_emails, lowercases and deduplicates the set, and optionally writes the updated values back.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description only contains sign-off and assistance attributions, not the pull request changes. Replace it with a brief summary of the email-normalization changes and their scope.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: downcasing user emails.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch unicron-downcase-user-emails

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR standardizes how user email addresses are stored and queried (specifically the user_emails DynamoDB attribute) by normalizing to lower-case and trimming whitespace, improving case-insensitive lookups and reducing DynamoDB String Set duplicate-member failures.

Changes:

  • Normalize user_emails values (lower-case + trim) when creating allowlist/approval request records (legacy + Go backend).
  • Normalize and de-duplicate user email sets via a new normalizeEmails helper when persisting users in the Go backend.
  • Normalize email input during GetUsersByEmail lookups and update one related log message.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

File Description
cla-backend-legacy/internal/api/handlers.go Normalizes stored user_emails values for legacy v2 allowlist request creation paths.
cla-backend-go/users/repository.go Adds email normalization/de-duplication on user writes; normalizes GetUsersByEmail lookups; updates log wording.
cla-backend-go/signatures/repository.go Normalizes email before searching users by user_emails during approval list updates.
cla-backend-go/approval_list/repository.go Normalizes stored user_emails for CCLA approval request records.

Comment thread cla-backend-go/users/repository.go Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 `@utils/downcase_emails.sh`:
- Around line 12-15: The backfill in downcase_emails.sh only lowercases and
deduplicates user_emails, but it still leaves leading/trailing spaces intact.
Update the jq processing in the main loop that reads each item and builds newss
so the normalization also trims whitespace before deduping, keeping the existing
uid and email backfill flow intact. Use the existing cat/jq pipeline and the
newss assignment as the place to apply the trim+lowercase normalization.
🪄 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: a3d63868-f5a7-43ed-af21-64cf5e972b4b

📥 Commits

Reviewing files that changed from the base of the PR and between a24c46c and 56157b8.

📒 Files selected for processing (5)
  • cla-backend-go/approval_list/repository.go
  • cla-backend-go/signatures/repository.go
  • cla-backend-go/users/repository.go
  • cla-backend-legacy/internal/api/handlers.go
  • utils/downcase_emails.sh

Comment thread utils/downcase_emails.sh Outdated
Signed-off-by: Lukasz Gryglicki <lgryglicki@cncf.io>

Assisted by [OpenAI](https://platform.openai.com/)

Assisted by [GitHub Copilot](https://github.com/features/copilot)

Assisted by [Claude](https://claude.ai)
Copilot AI review requested due to automatic review settings June 25, 2026 06:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Comment thread utils/downcase_emails.sh Outdated
Comment thread utils/downcase_emails.sh Outdated
Comment thread cla-backend-go/users/repository.go Outdated
Signed-off-by: Lukasz Gryglicki <lgryglicki@cncf.io>

Assisted by [OpenAI](https://platform.openai.com/)

Assisted by [GitHub Copilot](https://github.com/features/copilot)

Assisted by [Claude](https://claude.ai)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comment thread cla-backend-go/users/repository.go Outdated
Comment thread cla-backend-go/signatures/repository.go
Signed-off-by: Lukasz Gryglicki <lgryglicki@cncf.io>

Assisted by [OpenAI](https://platform.openai.com/)

Assisted by [GitHub Copilot](https://github.com/features/copilot)

Assisted by [Claude](https://claude.ai)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comment thread cla-backend-go/users/repository.go Outdated
Comment thread cla-backend-go/users/repository.go Outdated
Signed-off-by: Lukasz Gryglicki <lgryglicki@cncf.io>

Assisted by [OpenAI](https://platform.openai.com/)

Assisted by [GitHub Copilot](https://github.com/features/copilot)

Assisted by [Claude](https://claude.ai)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Comment thread cla-backend-go/users/repository.go
Comment thread cla-backend-go/signatures/repository.go
Comment thread cla-backend-go/approval_list/repository.go
Signed-off-by: Lukasz Gryglicki <lgryglicki@cncf.io>

Assisted by [OpenAI](https://platform.openai.com/)

Assisted by [GitHub Copilot](https://github.com/features/copilot)

Assisted by [Claude](https://claude.ai)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comment thread cla-backend-go/users/repository.go
Comment thread utils/downcase_emails.sh
Signed-off-by: Lukasz Gryglicki <lgryglicki@cncf.io>

Assisted by [OpenAI](https://platform.openai.com/)

Assisted by [GitHub Copilot](https://github.com/features/copilot)

Assisted by [Claude](https://claude.ai)
Signed-off-by: Lukasz Gryglicki <lgryglicki@cncf.io>

Assisted by [OpenAI](https://platform.openai.com/)

Assisted by [GitHub Copilot](https://github.com/features/copilot)

Assisted by [Claude](https://claude.ai)
Copilot AI review requested due to automatic review settings June 25, 2026 10:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.

Comment thread cla-backend-go/users/repository.go
@lukaszgryglicki lukaszgryglicki merged commit 02cdecf into dev Jun 25, 2026
15 checks passed
@lukaszgryglicki lukaszgryglicki deleted the unicron-downcase-user-emails branch June 25, 2026 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants