-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Problem
The current implementation of HTMLTemplRenderer.Instance
in internal/delivery/http/renderer/templ_renderer.go
has a silent failure mode that makes debugging difficult.
When the data parameter is not a templ.Component
and no fallback renderer is configured, the method returns a Renderer
with a nil
Component. This results in a 200 HTTP response with an empty body, which is hard to debug in production.
Current Behavior
func (r *HTMLTemplRenderer) Instance(s string, d any) render.Render {
templData, ok := d.(templ.Component)
if !ok {
if r.FallbackHtmlRenderer != nil {
return r.FallbackHtmlRenderer.Instance(s, d)
}
}
return &Renderer{
Ctx: context.Background(),
Status: -1,
Component: templData, // This is nil when type assertion fails
}
}
Expected Behavior
The renderer should fail fast and provide clear error information when:
- The data is not a
templ.Component
- No fallback renderer is available
Suggested Solution
Return an error render instance or nil to surface the programming error early, instead of silently creating a renderer with a nil component.
References
- PR: Feat/frontend #39
- Comment: Feat/frontend #39 (comment)
Metadata
Metadata
Assignees
Labels
No labels