iris: [BUG] View: If errors are returned by the ViewRenderer - do not output a "half template"
Describe the bug I am currently using the latest version from the Master Branch. If I use a template with Jet that uses variables that are not present, an error is returned, but the template is already sent to the browser as far as it has come, this should be prevented.
To Reproduce
We have tried with and without iris.WithResetOnFireErrorCode but without ctx.Record()
app.Get("/bug-test", func(ctx iris.Context) {
ctx.ViewData("demo", "123")
if err := ctx.View("bugtest.jet"); err != nil {
ctx.StopWithText(iris.StatusInternalServerError, "Templates not rendered!")
}
})
Expected behavior
Only the StopWithText should returned or the OnAnyErrorCode should be triggered. Not the half rendered Template.
I would expect, if a ViewEngine throws an error, that there will be no normal output, even if the template system has already sent it to the output.
An alternative would be to document it more clearly, in connection with the ViewEngines.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (8 by maintainers)
Commits related to this issue
- fix https://github.com/kataras/iris/issues/1569#issuecomment-663739177 Former-commit-id: c55f1023f4d93f6712c7fa4d299bcf1098872ecf — committed to kataras/iris by kataras 4 years ago
- correctly handle recorded compressed response see https://github.com/kataras/iris/issues/1569#issuecomment-664003098 — committed to kataras/iris by kataras 4 years ago
I thank you @Dexus, will take a look at the assesment for the certification of yours when I finish the documentation, I didnt forget it. I am freezing new features for v12.2.0.
It works now. Thanks @kataras
Just copy paste the most of it 😅 to not remove something that may have an impact.
Von meinem iPhone gesendet