-
Notifications
You must be signed in to change notification settings - Fork 376
Fix handlebars custom compiler in tRPC routes #2065
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: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: a13881f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for GitHub.
8 Skipped Deployments
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2065 +/- ##
==========================================
+ Coverage 34.64% 35.10% +0.46%
==========================================
Files 924 926 +2
Lines 59383 59659 +276
Branches 2818 2852 +34
==========================================
+ Hits 20574 20946 +372
+ Misses 38440 38346 -94
+ Partials 369 367 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
For some reason we are detecting changes in other apps (not touched in this PR)
I didn't have time to properly test this yet as well |
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.
Pull Request Overview
This PR fixes errors when configuring SMTP app by replacing direct Handlebars usage with a custom HandlebarsTemplateCompiler that includes all handlers. The fix prevents template compilation failures when using advanced Handlebars helpers.
Key changes:
- Replace direct Handlebars usage in tRPC routes with EmailCompiler validation
- Add comprehensive error handling and user-friendly error display components
- Implement template validation before saving configurations
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
apps/smtp/src/modules/trpc/trpc-server.ts | Add error context extraction for better error formatting in tRPC responses |
apps/smtp/src/modules/smtp/ui/template-preview.tsx | New component for displaying rendered email templates with loading states |
apps/smtp/src/modules/smtp/ui/template-error-display.tsx | New component for displaying template compilation errors with helpful hints |
apps/smtp/src/modules/smtp/ui/event-form.tsx | Update form to use new error display and preview components with improved UX |
apps/smtp/src/modules/smtp/services/mjml-compiler.ts | Improve error message handling to pass through original error messages |
apps/smtp/src/modules/smtp/services/handlebars-template-compiler.ts | Improve error message handling to pass through original error messages |
apps/smtp/src/modules/smtp/services/email-compiler.ts | Add error context types, validation method, and enhanced error handling |
apps/smtp/src/modules/smtp/configuration/smtp-configuration.service.ts | Add template validation before saving configurations |
apps/smtp/src/modules/smtp/configuration/smtp-configuration.router.ts | Replace direct Handlebars usage with EmailCompiler for proper handler support |
.changeset/giant-dolls-jump.md | Add changeset documenting the fix |
47e86eb
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.
Pull Request Overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
apps/smtp/src/modules/smtp/services/email-compiler.ts:1
- Using an empty object for validation may not catch all potential template errors that depend on specific payload structure. Consider using a more representative mock payload or documenting this limitation.
import { err, ok, Result } from "neverthrow";
apps/smtp/src/modules/smtp/configuration/smtp-configuration.router.ts
Outdated
Show resolved
Hide resolved
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.
Pull Request Overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
apps/smtp/src/modules/smtp/configuration/smtp-configuration.router.ts
Outdated
Show resolved
Hide resolved
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.
Pull Request Overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
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.
Pull Request Overview
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
<mj-section> | ||
<mj-column> | ||
<mj-text >{{injectedValue}}</mj-text> | ||
<mj-text >${{ injectedValue }}</mj-text> |
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.
Invalid template syntax. The ${{ injectedValue }}
syntax is incorrect - it should be {{ injectedValue }}
for Handlebars templating.
<mj-text >${{ injectedValue }}</mj-text> | |
<mj-text >{{ injectedValue }}</mj-text> |
Copilot uses AI. Check for mistakes.
Scope of the PR
This PR fixes errors when configuring SMTP app, by using correct Handlebars instance for parsing settings.
Previously it uses
Handlebars
, which did not include all handlers.It also introduces proper validation for email templates before saving them. We will validate templates when rendering preview and display error messages with helpful tips. Validation is also done on save to prevent corrupted templates.
For existing incorrect configurations we will no longer log them as errors, and instead will use
logger.warn
. Note we already send HTTP 400 for user errors to Saleor.Preview