Skip to content

Conversation

@rr-bw
Copy link
Contributor

@rr-bw rr-bw commented Nov 19, 2025

🎟️ Tracking

PM-27541

Stacked on top of:

📔 Objective

Adds an optional &fromMarketing=premium query parameter to the verification email link.

Feature flag: "pm-26140-marketing-initiated-premium-flow"

📸 Screenshots

For this test, instead of sending via the Marketing site form, I locally adjusted the request in clients to include fromMarketing: "premium" in the POST to /accounts/register/send/verification-email

Feature flags on for this test:

  • Server: "pm-26140-marketing-initiated-premium-flow"
  • Client: "pm-24033-updat-premium-subscription-page"
test-marketing-initiated-premium-flow.mov

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

@rr-bw rr-bw changed the base branch from main to auth/pm-27540/add-marketing-property-to-endpoint November 19, 2025 20:46
@github-actions
Copy link
Contributor

github-actions bot commented Nov 19, 2025

Logo
Checkmarx One – Scan Summary & Detailsa6ae578d-becf-4a97-82cc-e825f3f389e3

Great job! No new security vulnerabilities introduced in this pull request

@rr-bw rr-bw requested a review from ike-kottlowski November 20, 2025 06:29
@rr-bw rr-bw force-pushed the auth/pm-pm-27541/add-marketing-param-to-email-verification-link branch from 04bafc4 to e5473c9 Compare November 20, 2025 22:11
@rr-bw rr-bw marked this pull request as ready for review November 20, 2025 22:22
@rr-bw rr-bw requested review from a team as code owners November 20, 2025 22:22
@rr-bw rr-bw requested a review from dani-garcia November 20, 2025 22:22
@claude
Copy link
Contributor

claude bot commented Nov 20, 2025

Claude finished @rr-bw's task —— View job


Code Review Complete

Summary

This PR adds an optional fromMarketing query parameter to the email verification link, controlled by the pm-26140-marketing-initiated-premium-flow feature flag. The implementation is clean and well-tested. I identified one critical security issue, one minor improvement opportunity, and noted several good practices.


Critical Issues

Finding 1: URL encoding applied twice results in double-encoded parameters

In HandlebarsMailService.cs:90, the fromMarketing parameter is URL-encoded before being assigned to the model:

FromMarketing = WebUtility.UrlEncode(fromMarketing),

Then in RegisterVerifyEmail.cs:22, it's concatenated into the URL without additional encoding:

!string.IsNullOrEmpty(FromMarketing) ? $"&fromMarketing={FromMarketing}" : string.Empty);

Problem: If fromMarketing contains the value "premium", it will be double-encoded:

  • First encoding: "premium""premium" (no change, but still encoded)
  • The issue arises if fromMarketing is already null or contains special characters

However, the real issue is encoding null:

  • WebUtility.UrlEncode(null) returns null, not an empty string
  • But the check !string.IsNullOrEmpty(FromMarketing) will still pass for an empty string

Recommendation: Only encode fromMarketing when constructing the URL, not when assigning to the model property:

Suggested fix
// In HandlebarsMailService.cs:90
FromMarketing = fromMarketing, // Don't encode here

// In RegisterVerifyEmail.cs:22
!string.IsNullOrEmpty(FromMarketing) ? $"&fromMarketing={WebUtility.UrlEncode(FromMarketing)}" : string.Empty);

Files: src/Core/Platform/Mail/HandlebarsMailService.cs:90, src/Core/Auth/Models/Mail/RegisterVerifyEmail.cs:22


Suggested Improvements

Finding 2: Missing XML documentation for new parameter

The fromMarketing parameter is added to several interfaces and implementations without XML documentation explaining its purpose, validation rules, or relationship to the feature flag.

Recommendation: Add XML documentation to clarify the parameter's purpose:

Suggested documentation
/// <summary>
/// Sends a registration verification email to the specified email address.
/// </summary>
/// <param name="email">The recipient email address</param>
/// <param name="token">The verification token</param>
/// <param name="fromMarketing">Optional marketing initiative identifier (e.g., "premium"). 
/// When provided, adds a query parameter to guide post-registration flow. 
/// Must be validated using MarketingInitiativeValidationAttribute.</param>
Task SendRegistrationVerificationEmailAsync(string email, string token, string? fromMarketing);

Files: src/Core/Platform/Mail/IMailService.cs:41, src/Core/Auth/UserFeatures/Registration/ISendVerificationEmailForRegistrationCommand.cs:6


Good Practices Observed

  • Feature flag properly guards the new functionality in AccountsController.cs:112-115
  • Comprehensive test coverage including feature flag enabled/disabled scenarios
  • Input validation using custom MarketingInitiativeValidationAttribute
  • Proper use of nullable reference types throughout
  • Tests verify both the presence and absence of the marketing parameter

Additional Notes

Test Coverage

Codecov reports 40% patch coverage with 6 lines missing coverage in:

  • RegisterVerifyEmail.cs (4 lines)
  • HandlebarsMailService.cs (2 lines)

The missing coverage appears to be in the property assignments and URL construction logic. Consider adding integration tests that verify the actual email content and URL structure.

Security Considerations

  • Input validation is properly implemented via MarketingInitiativeValidationAttribute
  • URL encoding prevents injection attacks (though double-encoding issue noted above)
  • Feature flag ensures controlled rollout
  • No PII or sensitive data logged

PR Metadata Assessment

Title: ✅ Clear and specific

Objective: ✅ Well-explained with Jira reference and stacked PR context

Test Plan: ⚠️ Missing - No explicit test plan provided. The PR description should include manual testing steps or reference a test plan in the Jira task.

Suggestion: Add a test plan section describing how to manually verify:

  1. Feature flag disabled → parameter not included in email link
  2. Feature flag enabled + valid fromMarketing value → parameter included correctly
  3. Feature flag enabled + invalid fromMarketing value → validation error
  4. Feature flag enabled + null fromMarketing → parameter not included

@rr-bw rr-bw marked this pull request as draft November 20, 2025 22:28
@codecov
Copy link

codecov bot commented Nov 20, 2025

Codecov Report

❌ Patch coverage is 40.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.99%. Comparing base (0422796) to head (d989ea1).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
src/Core/Auth/Models/Mail/RegisterVerifyEmail.cs 0.00% 4 Missing ⚠️
src/Core/Platform/Mail/HandlebarsMailService.cs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6604      +/-   ##
==========================================
- Coverage   52.99%   52.99%   -0.01%     
==========================================
  Files        1910     1910              
  Lines       84843    84848       +5     
  Branches     7636     7638       +2     
==========================================
- Hits        44966    44965       -1     
- Misses      38125    38130       +5     
- Partials     1752     1753       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rr-bw rr-bw marked this pull request as ready for review November 20, 2025 22:43
@rr-bw rr-bw marked this pull request as draft November 20, 2025 22:49
@rr-bw rr-bw marked this pull request as ready for review November 20, 2025 22:59
@sonarqubecloud
Copy link

dani-garcia
dani-garcia previously approved these changes Nov 21, 2025
Copy link
Member

@dani-garcia dani-garcia left a comment

Choose a reason for hiding this comment

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

Platform changes LGTM

Base automatically changed from auth/pm-27540/add-marketing-property-to-endpoint to main November 21, 2025 17:39
@rr-bw rr-bw dismissed dani-garcia’s stale review November 21, 2025 17:39

The base branch was changed.

@rr-bw rr-bw force-pushed the auth/pm-pm-27541/add-marketing-param-to-email-verification-link branch from 52b38b0 to d989ea1 Compare November 21, 2025 19:35
@rr-bw rr-bw requested a review from dani-garcia November 21, 2025 21:36
@rr-bw rr-bw merged commit 5fb69e4 into main Nov 24, 2025
48 checks passed
@rr-bw rr-bw deleted the auth/pm-pm-27541/add-marketing-param-to-email-verification-link branch November 24, 2025 23:06
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.

4 participants