refactor(api/alerts): route runtime values through the Handlebars view#2278
Conversation
Alert bodies for saved-search and resolved alerts previously interpolated
`group` and the truncated query results into the Handlebars template source
via JS template literals, then compiled the result. Route both through the
view instead and reference them via template syntax
(`{{#if group}}{{{group}}}{{/if}}`, `{{{__hdx_query_results__}}}`), matching
how the rest of the template already handles dynamic values.
Adds regression tests covering literal rendering of Handlebars-like
substrings in those inputs. Snapshots unchanged.
🦋 Changeset detectedLatest commit: cb4b9b6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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.
|
🔴 Tier 4 — CriticalTouches auth, data models, config, tasks, OTel pipeline, ClickHouse, or CI/CD. Why this tier:
Review process: Deep review from a domain expert. Synchronous walkthrough may be required. Stats
|
PR Review✅ No critical issues found. Clean, well-scoped fix. Routing
|
E2E Test Results✅ All tests passed • 178 passed • 3 skipped • 1180s
Tests ran across 4 shards in parallel. |
Deep Review✅ No critical issues found. This PR removes a real Handlebars template-injection surface by routing untrusted 🔵 P3 nitpicks (2)
Reviewers (5): correctness, security, testing, maintainability, project-standards |
Summary
Alert bodies for saved-search and resolved alerts previously interpolated
groupand the truncated query results into the Handlebars template source via JS template literals, then compiled the result. Route both through the view instead and reference them via template syntax ({{#if group}}{{{group}}}{{/if}},{{{__hdx_query_results__}}}), matching how the rest of the template already handles dynamic values.Adds regression tests covering literal rendering of Handlebars-like substrings in those inputs.
Test plan
npx jest src/tasks/checkAlerts/__tests__/renderAlertTemplate.test.ts— 74 passed, 72 snapshots unchangedyarn lint+tsc --noEmitonpackages/api— cleangroup; both assert the substring renders literally and is not re-evaluated as template sourceAdditional notes