fix(notifications): reseed the 023 templates and report unresolved keys #470

Merged
Claude-Run merged 1 commit from fix/PMS-702-reseed-notification-templates into main 2026-08-01 02:26:11 +02:00
Member

Migration 023 seeded eight notification templates that could never render. The bodies were plain single-quoted literals, so with standard_conforming_strings on every \n was stored as a literal backslash + n and the mail would arrive as one long line, and every placeholder was dotted ({{ticket.number}}) while render_template resolves flat top-level context keys only and re-emits unresolved braces verbatim. Migration 021 already documents both requirements.

Migration 096 rewrites those rows in place with E'...' literals and flat keys (ticket_number, company_name, invoice_total, ...) that follow the existing ticket.note_added context. 023 itself is untouched: migrations are immutable and editing an applied one makes deployed databases refuse to boot. Each UPDATE is guarded on the dotted placeholder still being present, so an operator-customized row is left alone and re-running is a no-op.

render_template now returns the de-duplicated list of keys it could not resolve and dispatch warns on any, so a future template typo shows up in the logs instead of in a customer's inbox. The rmm alert-title renderer keeps its existing behaviour.

A new #[sqlx::test] in tests/notifications.rs scans every migration-seeded template and fails on a literal backslash-n or a dotted placeholder in any subject or body, so neither defect can come back.

#PMS-702

Migration 023 seeded eight notification templates that could never render. The bodies were plain single-quoted literals, so with standard_conforming_strings on every `\n` was stored as a literal backslash + n and the mail would arrive as one long line, and every placeholder was dotted (`{{ticket.number}}`) while `render_template` resolves flat top-level context keys only and re-emits unresolved braces verbatim. Migration 021 already documents both requirements. Migration 096 rewrites those rows in place with `E'...'` literals and flat keys (`ticket_number`, `company_name`, `invoice_total`, ...) that follow the existing `ticket.note_added` context. 023 itself is untouched: migrations are immutable and editing an applied one makes deployed databases refuse to boot. Each UPDATE is guarded on the dotted placeholder still being present, so an operator-customized row is left alone and re-running is a no-op. `render_template` now returns the de-duplicated list of keys it could not resolve and `dispatch` warns on any, so a future template typo shows up in the logs instead of in a customer's inbox. The rmm alert-title renderer keeps its existing behaviour. A new `#[sqlx::test]` in tests/notifications.rs scans every migration-seeded template and fails on a literal backslash-n or a dotted placeholder in any subject or body, so neither defect can come back. #PMS-702
fix(notifications): reseed the 023 templates and report unresolved keys
All checks were successful
E2E / Playwright against staging (pull_request) Successful in 47s
Check / fmt + clippy + build + tests (pull_request) Successful in 2m16s
Integration / integration tests (pull_request) Successful in 9m48s
Create release / Gate (release-branch merges only) (pull_request) Successful in 1s
Create release / Create release from merged PR (pull_request) Has been skipped
f646985fad
Migration 023 seeded eight notification templates that could never render. The bodies were plain single-quoted literals, so with standard_conforming_strings on every `\n` was stored as a literal backslash + n and the mail would arrive as one long line, and every placeholder was dotted (`{{ticket.number}}`) while `render_template` resolves flat top-level context keys only and re-emits unresolved braces verbatim. Migration 021 already documents both requirements.

Migration 096 rewrites those rows in place with `E'...'` literals and flat keys (`ticket_number`, `company_name`, `invoice_total`, ...) that follow the existing `ticket.note_added` context. 023 itself is untouched: migrations are immutable and editing an applied one makes deployed databases refuse to boot. Each UPDATE is guarded on the dotted placeholder still being present, so an operator-customized row is left alone and re-running is a no-op.

`render_template` now returns the de-duplicated list of keys it could not resolve and `dispatch` warns on any, so a future template typo shows up in the logs instead of in a customer's inbox. The rmm alert-title renderer keeps its existing behaviour.

A new `#[sqlx::test]` in tests/notifications.rs scans every migration-seeded template and fails on a literal backslash-n or a dotted placeholder in any subject or body, so neither defect can come back.

#PMS-702
Claude-Run deleted branch fix/PMS-702-reseed-notification-templates 2026-08-01 02:26:12 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/mokosh-server!470
No description provided.