Skip to content

fix: workflow locale#26509

Merged
Ryukemeister merged 12 commits intomainfrom
fix/workflow-locale
Jan 14, 2026
Merged

fix: workflow locale#26509
Ryukemeister merged 12 commits intomainfrom
fix/workflow-locale

Conversation

@Udit-takkar
Copy link
Contributor

@Udit-takkar Udit-takkar commented Jan 6, 2026

What does this PR do?

This PR fixes the issue when workflow reminder body isn't translated to attendee's locale.

image

Updates since last revision

Latest (hariombalhara's feedback): Extracted the template matching logic into a separate testable function with comprehensive unit tests.

Changes:

  • Created detectMatchedTemplate function in packages/features/ee/workflows/lib/detectMatchedTemplate.ts
  • Added 20 unit tests covering all edge cases (empty body, body/subject matching, HTML stripping, null defaults, etc.)
  • Refactored EmailWorkflowService to use the new function

Previous (CarinaWolli's feedback): Now checks both email body AND subject against default templates before regenerating with recipient's locale. Previously only the body was checked, which meant a customized subject would be overwritten with the default when the body matched the template.

Changes:

  • Added getTemplateSubjectForAction helper function to get default subject for templates
  • Updated template matching logic to require both body AND subject to match defaults
  • If either is customized, falls through to customTemplate() path to preserve user edits

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  1. Create a workflow with EMAIL_ATTENDEE action using REMINDER template
  2. Customize only the subject (keep default body) and save
  3. Trigger the workflow - verify the custom subject is preserved (not overwritten with default)
  4. Test with default subject + default body - verify translation works for attendee's locale

Human Review Checklist

  • Verify detectMatchedTemplate function behavior matches the original inline logic
  • Verify subject comparison uses strict equality while body uses HTML-stripped comparison (intentional since subjects don't contain HTML)
  • Check edge case: when emailBody is empty but template is specified, subject customization is not checked (matches original behavior)
  • Review the 20 unit tests in detectMatchedTemplate.test.ts for completeness

Link to Devin run: https://app.devin.ai/sessions/fd81f5a877f447aaa8112dd55148953d
Requested by: udit@cal.com (@Udit-takkar)

@vercel
Copy link

vercel bot commented Jan 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

4 Skipped Deployments
Project Deployment Review Updated (UTC)
api-v2 Ignored Ignored Preview Jan 8, 2026 9:05am
cal Ignored Ignored Jan 8, 2026 9:05am
cal-companion Ignored Ignored Preview Jan 8, 2026 9:05am
cal-eu Ignored Ignored Jan 8, 2026 9:05am

@Udit-takkar Udit-takkar marked this pull request as ready for review January 6, 2026 16:04
@graphite-app graphite-app bot requested a review from a team January 6, 2026 16:04
@graphite-app graphite-app bot added enterprise area: enterprise, audit log, organisation, SAML, SSO core area: core, team members only labels Jan 6, 2026
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 2 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/features/ee/workflows/lib/service/EmailWorkflowService.ts">

<violation number="1" location="packages/features/ee/workflows/lib/service/EmailWorkflowService.ts:418">
P1: Potential regression when `reminderBody` is null but `template` is REMINDER/RATING. The old code would generate the default template from the `template` parameter, but the new code only generates templates when `matchedTemplate` is set (which requires `emailBody` to be truthy). Consider adding a fallback to check the `template` parameter when `emailBody` is empty:

```javascript
} else if (emailBody) {
  // custom processing
} else if (template === WorkflowTemplates.REMINDER) {
  // Generate REMINDER with correct locale (fallback for empty body)
} else if (template === WorkflowTemplates.RATING) {
  // Generate RATING with correct locale (fallback for empty body)
}
```</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@Udit-takkar Udit-takkar added the High priority Created by Linear-GitHub Sync label Jan 8, 2026
Copy link
Member

@CarinaWolli CarinaWolli left a comment

Choose a reason for hiding this comment

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

We are only checking for changes in the email body and not the subject. So if only the subject was changed for the reminder template, then we are doing the translation using the default reminder subject instead of sending the custom email subject

@github-actions github-actions bot marked this pull request as draft January 8, 2026 12:21
@ThyMinimalDev ThyMinimalDev marked this pull request as ready for review January 12, 2026 07:52
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 3 files

@github-actions
Copy link
Contributor

github-actions bot commented Jan 12, 2026

E2E results are ready!

@vercel vercel bot temporarily deployed to Preview – cal-companion January 13, 2026 08:53 Inactive
@vercel vercel bot temporarily deployed to Preview – dev January 13, 2026 08:53 Inactive
Copy link
Member

@hariombalhara hariombalhara left a comment

Choose a reason for hiding this comment

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

There is a scope of code quality improvement and I think tests are also required

@github-actions github-actions bot marked this pull request as draft January 13, 2026 13:20
- Create detectMatchedTemplate function in separate file
- Add comprehensive unit tests (20 test cases)
- Refactor EmailWorkflowService to use the new function

Addresses review comment from hariombalhara requesting
abstraction and tests for the template matching logic.

Co-Authored-By: udit@cal.com <udit222001@gmail.com>
@ThyMinimalDev ThyMinimalDev marked this pull request as ready for review January 13, 2026 14:24
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 5 files

Copy link
Member

@hariombalhara hariombalhara left a comment

Choose a reason for hiding this comment

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

LGTM !!

@Ryukemeister Ryukemeister merged commit 3860717 into main Jan 14, 2026
49 checks passed
@Ryukemeister Ryukemeister deleted the fix/workflow-locale branch January 14, 2026 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO High priority Created by Linear-GitHub Sync ready-for-e2e size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

Comments