Skip to content

🐛(backend) keep the case of titles and names in email subjects - #2794

Merged
AntoLC merged 2 commits into
suitenumerique:mainfrom
RoeeSivan:fix/email-subject-case-2792
Nov 4, 2026
Merged

AntoLC merged 2 commits into
suitenumerique:mainfrom
RoeeSivan:fix/email-subject-case-2792

Conversation

@RoeeSivan

@RoeeSivan RoeeSivan commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

Fixes #2792. Email subjects went through str.capitalize(), which lowercases
every character after the first, so names and document titles lost their case:
Anne Martin mentioned you in "Budget 2026" was sent as
Anne martin mentioned you in "budget 2026".

Proposal

  • Use django's capfirst instead of str.capitalize() in the three
    send_email methods (User, UserReconciliationCsvImport, Document):
    it only uppercases the first letter, which still matters for subjects
    starting with a lowercase user name or passed in by the caller.
  • Tighten the mention tests: they compared email.subject.lower(), which
    hid the bug. They now compare the exact subject.
  • Fix the expected subject in
    test_models_documents__email_invitation__success_empty_title, which
    asserted the lowercased Test sender.
  • Pin the mentioned user's language to en-us in
    test_api_documents_mention_thread, like the other mention test does:
    the factory picks a random language, and fr-fr / nl-nl translate this
    subject, so the test failed about 2 runs in 5.

External contributions

Thank you for your contribution! 🎉

Please ensure the following items are checked before submitting your pull request:

General requirements

Skip the checkbox below 👇 if you're fixing an issue or adding documentation

  • Before submitting a PR for a new feature I made sure to contact the product manager

CI requirements

  • I made sure that all existing tests are passing
  • I have signed off my commits with git commit --signoff (DCO compliance)
  • I have signed my commits with my SSH or GPG key (git commit -S)
  • My commit messages follow the required format: <gitmoji>(type) title description
  • I have added a changelog entry under ## [Unreleased] section (if noticeable change)

AI requirements

Skip the checkboxes below 👇 If you didn't use AI for your contribution

  • I used AI assistance to produce part or all of this contribution
  • I have read, reviewed, understood and can explain the code I am submitting
  • I can jump in a call or a chat to explain my work to a maintainer

@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Three email methods now use Django’s capfirst rather than Python’s str.capitalize when formatting translated subjects. Updated tests check capitalization in invitation and mention email subjects. The Unreleased changelog records the fix. The environment-variable documentation moves the POSTHOG_HOST row; its descriptions and defaults are unchanged.

Estimated code review effort: 2 (Simple) | ~10 minutes

Severity of issue fixed: Medium

Suggested reviewers: maboukerfa

Merge Risk: Minimal · up to 3799e

The change preserves name and title casing in email subjects without altering recipients or language selection. No actionable merge-blocking risk was found; merge after normal checks pass.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Out of Scope Changes check Warning The email code changes, subject assertions, locale fix, and changelog entry support issue #2792. The documentation/env.md change only moves the POSTHOG_HOST row before POSTHOG_KEY and does not r… Remove the unrelated row reordering in documentation/env.md, or provide a direct coding requirement that requires this documentation change.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: preserving the case of titles and names in backend email subjects.
Description check Passed The description directly explains the email subject casing bug, the proposed fix, and the related test updates.
Linked Issues check Passed Issue #2792 requires email subjects to preserve document-title and user-name case in the three affected send_email methods. The PR replaces str.capitalize() with Django capfirst in `User.send_em…
Docstring Coverage Passed Docstring coverage is inconclusive: files from earlier reviews still need to be rechecked within the check's analysis limits. Not blocking.
Full details: Linked Issues check

Explanation

Issue #2792 requires email subjects to preserve document-title and user-name case in the three affected send_email methods. The PR replaces str.capitalize() with Django capfirst in User.send_email, UserReconciliationCsvImport.send_email, and Document.send_email. The updated tests compare exact subjects and use a fixed English locale where required.

Full details: Out of Scope Changes check

Explanation

The email code changes, subject assertions, locale fix, and changelog entry support issue #2792. The documentation/env.md change only moves the POSTHOG_HOST row before POSTHOG_KEY and does not relate to email subject case or its tests.

Resolution

Remove the unrelated row reordering in documentation/env.md, or provide a direct coding requirement that requires this documentation change.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share
Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: d4a3e2f6-5ac4-4c3a-8ecb-8ab0d383300a
Commits

Reviewing files that changed from the base of the PR and between 543a1ad and 3799ef6.

Files selected for processing: 4
  • CHANGELOG.md
  • documentation/env.md
  • src/backend/core/models.py
  • src/backend/core/tests/test_models_documents.py

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@AntoLC
AntoLC requested a review from lunika October 8, 2026 08:20
@AntoLC AntoLC added bug Something isn't working backend labels Oct 8, 2026
RoeeSivan and others added 2 commits November 4, 2026 15:46
str.capitalize() lowercased every character after the first, so
document titles and user names in email subjects lost their case.
Use django's capfirst to only uppercase the first letter.

Signed-off-by: Roee Sivan <[email protected]>
Put POSTHOG-related variables together
@AntoLC
AntoLC force-pushed the fix/email-subject-case-2792 branch from 543a1ad to 3799ef6 Compare November 4, 2026 14:48
@AntoLC
AntoLC merged commit 3799ef6 into suitenumerique:main Nov 4, 2026
45 checks passed
@AntoLC AntoLC mentioned this pull request Nov 4, 2026
3 of 13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛(Bug) Email subjects lowercase document titles and user names

4 participants