You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 807cd9a
Browse filesBrowse the repository at this point in the historyBrowse files
fix(app): show webhook body template compile errors in the editor (#3350)
## Summary
The webhook form now compiles the body template as you edit it and shows the Handlebars error under the editor, with its line and column. A template that doesn't compile used to save without any feedback, and the problem only surfaced when an alert failed to deliver (visible in server logs).
The common case is JSON-escaping quotes inside a Handlebars expression:
```
"status": "{{#if (eq state \"ALERT\")}}firing{{else}}resolved{{/if}}"
```
That's valid JSON but not a valid template. The form now shows `Template error on line 1, column 29` with Handlebars' parse message. The intended template, `{{#if (eq state "ALERT")}}`, is invalid JSON as written but compiles, so it shows no error.
- The check runs 300 ms after typing stops, so the error doesn't flash while a `{{ … }}` is half-typed. Empty bodies are skipped, since they fall back to the service's default template. Slack bodies are skipped too; Slack never renders the body.
- `getWebhookTemplateError` in common-utils uses `Handlebars.precompile`. Delivery's extra `eq` helper only matters at render time, so stock Handlebars reports the same compile errors delivery would hit.
- The docs example in `alert-webhook-template-variables.md` used the escaped-quote pattern itself and would not have compiled; it's fixed, and the page now explains how to quote strings inside `{{ … }}`.
### Screenshots or video
| Before | After |
| :----- | :---- |
| <img width="1296" height="341" alt="Screenshot 2026-10-09 at 3 32 34 PM" src="https://github.com/user-attachments/assets/974209f9-9aff-479d-a91f-8342afe7e013" /> | <img width="1266" height="551" alt="Screenshot 2026-10-09 at 3 32 02 PM" src="https://github.com/user-attachments/assets/f089a38f-7d7e-483c-af85-f26483b36a1f" /> |
### How to test on Vercel preview
**Preview routes:** /team
**Steps:**
1. Click the button with `data-testid="add-webhook-section-button"` to open the webhook form.
2. Select the "incident.io" service type.
3. In the body editor, enter `{"status": "{{#if (eq state \"ALERT\")}}firing{{/if}}"}` and wait a moment.
4. Verify an error titled "Template error on line 1, column 29" appears under the editor.
5. Replace the body with `{"status": "{{#if (eq state "ALERT")}}firing{{/if}}"}` and verify the error disappears.
### References
- Linear Issue: [HDX-5681](https://linear.app/clickhouse/issue/HDX-5681/validate-webhook-body-templates-when-they-are-saved-not-at-delivery)
- Related PRs:
0 commit comments