-
-
Notifications
You must be signed in to change notification settings - Fork 153
fix: allow @ in the username #1438
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
fix: allow @ in the username #1438
Conversation
WalkthroughExpanded validation in src/validator.rs to allow '@' in user_role_name while keeping existing rules: alphanumerics allowed, no consecutive special characters. No public API or signature changes. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/validator.rs (1)
121-126
: Update error messages and external validators to include '@'Validator logic permits '@' (src/validator.rs ~lines 121–126) but the error strings still say "underscore, hyphen and dot" (src/validator.rs:188, :196). Update those messages and any UI/docs/CLI regexes/patterns (e.g. [A-Za-z0-9_.-]) to include '@'.
🧹 Nitpick comments (3)
src/validator.rs (3)
187-190
: Error messages now outdated; add '@' to allowed listMessages still say “underscore, hyphen and dot” but code allows '@'. Update both variants.
Apply:
- "Username contains invalid characters. Only alphanumeric characters and special characters (underscore, hyphen and dot) are allowed" + "Username contains invalid characters. Only alphanumeric characters and special characters (underscore, hyphen, dot, and '@') are allowed"(Do this for both SpecialChar and InvalidCharacter.)
Also applies to: 195-198
112-132
: Start‑char rule is undocumented/inconsistentThere’s an InvalidStartChar variant, but no start‑char check. Either enforce it or remove/deprecate the variant.
Option A (enforce start alnum):
// Check last character (must be alphanumeric) if let Some(last_char) = chars.last() && !last_char.is_ascii_alphanumeric() { return Err(UsernameValidationError::InvalidEndChar); } + // Check first character (must be alphanumeric) + if let Some(first_char) = chars.first() + && !first_char.is_ascii_alphanumeric() + { + return Err(UsernameValidationError::InvalidStartChar); + }Option B (drop the rule): deprecate or remove InvalidStartChar.
Also applies to: 191-193
184-203
: Duplicate/unused error variantSpecialChar and InvalidCharacter carry the same meaning; SpecialChar appears unused. Consider deprecating to avoid API confusion.
Apply:
- #[error( + #[deprecated(note = "Use InvalidCharacter instead")] + #[error( "Username contains invalid characters. Only alphanumeric characters and special characters (underscore, hyphen, dot, and '@') are allowed" )] SpecialChar,
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/validator.rs
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
- GitHub Check: Quest Smoke and Load Tests for Distributed deployments
- GitHub Check: Quest Smoke and Load Tests for Standalone deployments
- GitHub Check: Build Default aarch64-apple-darwin
- GitHub Check: Build Default x86_64-unknown-linux-gnu
- GitHub Check: Build Default x86_64-pc-windows-msvc
- GitHub Check: Build Default aarch64-unknown-linux-gnu
- GitHub Check: Build Default x86_64-apple-darwin
- GitHub Check: Build Kafka aarch64-apple-darwin
- GitHub Check: Build Kafka x86_64-unknown-linux-gnu
- GitHub Check: coverage
🔇 Additional comments (2)
src/validator.rs (2)
121-126
: Do we want to cap '@' to a single occurrence?Current logic permits multiple '@' if separated by alnum (e.g., a@b@c). If the intent is “email‑like usernames,” consider restricting to at most one '@'. Otherwise, ignore.
94-96
: Length check: confirm system limits3–64 is reasonable, but please verify this matches DB column limits, auth provider constraints, and UI validations to avoid cross‑layer rejects.
Summary by CodeRabbit