Invental/Review lessons/Trust boundaries the server must hold

Trust boundaries the server must hold

Validate templates after variables are filled

Sanitise and derive after template variables are filled in, not before: a URL check that runs on {{url}} will either reject a good link or approve a placeholder. And never guess a data format on a shared write path; convert where the format is known.

01 · Before and afterThe pattern

TypeScript
// before: build the rich doc (and validate links) from the template
const doc = buildBlocks(template);           // isSafeUrl("{{event.url}}") -> false, link dropped
return resolveVariables(doc, context);
// after: resolve into the plain form first, derive and validate last
const markdown = resolveVariables(templateToMarkdown(template), context);
return { markdown, richText: markdownToBlocks(markdown) }; // isSafeUrl sees the real URL

02 · Run it on your appThe check

Where your app fills templates (emails, workflow actions, AI prompts), does validation or escaping run on the filled-in value, or on the placeholder?

If the honest answer is no or not sure, this is worth a look before it reaches production.

Want this checked on your code?

Tell us what you are building and what worries you. We match a senior reviewer to your code and confirm scope before anything starts.

— Get in touch
hi@invental.co ↗
— Or
— What to include

A link or short description of the code or system, what you want checked, your stack, and when you need the answer. No repository access is needed until scope is agreed.

— Or leave a note
We reply within one business day.