Repository navigation
STTEDIT-4 Show backend error details in the template preview - #121
Merged
Merged
Conversation
The preview discarded the error object from the preview request, so a failed render only produced a generic message. mod-template-engine returns a diagnostic and, depending on the resolver, a source line with a caret; that detail is now extracted in the query function and shown below the generic message. Extraction happens in the queryFn because reading the response body is async while react-query exposes `error` synchronously.
thomas-sc
marked this pull request as ready for review
August 19, 2026 09:00
zburke
approved these changes
Aug 19, 2026
zburke
left a comment
Member
There was a problem hiding this comment.
Your detailed explanation of both the implementation and why we need it was super helpful; thank you!
Contributor
Author
|
Thanks @zburke , glad it was helpful. Is anything else needed to merge? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A failed backend-rendered preview only showed the generic "The preview could not be rendered."
useTemplatePreviewdropped the error object, so the diagnostic thatmod-template-enginereturns was lost. A syntax error in a large template is currently a needle in a haystack.queryFn(reading the response body is async whileerroris exposed synchronously) and attached to the thrown error.BackendPreviewrenders the diagnostic below the existing generic message, plus a short excerpt of the source line with a caret where the response carries one; the full template dump is not rendered.errors[].message); with no extractable detail the generic message is shown on its own.How much detail arrives depends on the resolver: mustache.java returns one line without a position, the Handlebars resolver from MODTEMPENG-136 adds a source line and a caret. The parser does not assume the richer shape, so MODTEMPENG-136 is not a prerequisite. Both real responses are used as test fixtures.
Backwards compatible: no new or changed props, no dependency changes. Only the existing error state gains detail, and it is reachable solely for consumers that already opted into
previewRenderer="backend". ui-circulation and staff slips keep the regex preview. No new interactive UI, so accessibility is unchanged.mustache.java — diagnostic line only, no excerpt:

Handlebars (MODTEMPENG-136) — diagnostic, excerpt and caret:

Refs STTEDIT-4