-
Notifications
You must be signed in to change notification settings - Fork 3
fix: capture all kinds of emails in workspace-invite csv input #809
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: master
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughReworked email parsing in routers/workspace.py: validate_emails_csv now extracts emails using a compiled regex (email_re) via findall instead of splitting by delimiters. Deduplication and normalization are done with a set comprehension that lowercases entries. The result is converted back to a list and truncated to max_emails. Validation still uses validate_email and raises ValidationError on invalid entries. The function signature and return type remain unchanged, and delimiter-related code was removed. Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal). Please share your feedback with us on this Discord post. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 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
🧹 Nitpick comments (2)
routers/workspace.py (2)
292-292
: Broaden local-part, tighten domain labels in regex (more capture, fewer false positives).Current pattern misses valid chars like
'!#$&*=/{}?^~
and wrongly allows_
in domain labels. Recommend:
- Local-part: allow RFC‑5322 common set.
- Domain:
[A-Za-z0-9-]
labels, TLD 2–63.Apply this diff:
-email_re = re.compile(r"[\w\-\.+%]+@(?:[\w-]+\.)+[\w-]{2,}") +# More permissive local-part, stricter domain labels (extraction only; Django validate_email does final validation) +email_re = re.compile( + r"[A-Za-z0-9.!#$%&'*+/=?^_`{|}~-]+@(?:[A-Za-z0-9-]+\.)+[A-Za-z]{2,63}" +)
298-301
: Avoid nondeterministic truncation; preserve order and lowercase domain only.
- Set destroys input order; slicing after it can invite an arbitrary subset when >max_emails.
- Lowercasing entire address alters case of local-part (technically case‑sensitive). Prefer domain‑only lowercasing and case‑insensitive dedup keys.
Apply this diff:
-emails = email_re.findall(emails_csv) -emails = {email.lower() for email in emails} # lowercase + remove duplicates -emails = list(emails)[:max_emails] # take up to max_emails from the list +# Preserve input order, dedupe case-insensitively, and lowercase domain only +seen = set() +emails = [] +for m in email_re.finditer(emails_csv): + e = m.group(0) + local, _, domain = e.rpartition("@") + normalized = f"{local}@{domain.lower()}" if domain else e + key = normalized.casefold() + if key not in seen: + seen.add(key) + emails.append(normalized) +emails = emails[:max_emails]Note: Consider updating the textarea label (Lines 236–238) to drop “separated by commas” since parsing is now free‑form.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
routers/workspace.py
(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). (1)
- GitHub Check: test (3.10.12, 1.8.3)
Q/A checklist
How to check import time?
You can visualize this using tuna:
To measure import time for a specific library:
To reduce import times, import libraries that take a long time inside the functions that use them instead of at the top of the file:
Legal Boilerplate
Look, I get it. The entity doing business as “Gooey.AI” and/or “Dara.network” was incorporated in the State of Delaware in 2020 as Dara Network Inc. and is gonna need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Dara Network Inc can use, modify, copy, and redistribute my contributions, under its choice of terms.