[MAGNOLIA-8227] Response.setStatus causing templating error Created: 16/Nov/21 Updated: 02/Dec/21 Resolved: 02/Dec/21 |
|
| Status: | Closed |
| Project: | Magnolia |
| Component/s: | None |
| Affects Version/s: | 6.2.13 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Neutral |
| Reporter: | Leah Staniorski | Assignee: | Unassigned |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | maintenance | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||
| Issue Links: |
|
||||
| Template: | |||||
| Acceptance criteria: |
Empty
|
||||
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
||||
| Bug DoR: |
[ ]*
Steps to reproduce, expected, and actual results filled
[ ]*
Affected version filled
|
||||
| Date of First Response: | |||||
| Description |
Steps to reproduce
${ctx.getResponse().setStatus(404)} directly below the following line: Save template.
Expected resultsNot to see this error when I edit page in the Pages app. Actual resultsError shown in screenshot11. There is an error message and no green bars for areas available. WorkaroundNone that I could find. |
| Comments |
| Comment by Bradley Andersen [ 02/Dec/21 ] |
|
Hi skaushik -
You should not be setting status from a template. It's a public method in the response so there's no way to take it out. This is especially true in the case of a 404. HTTP 404 indicates that the page was not found, but if we are processing the template, the uri/page exists, so 404 is not an acceptable status in that context and should throw an error.
Additionally, the J2EE/Jakarta specification says you are not allowed to change the response status once the server has already written to the response. When the template is processed it might have already happened, hence there is no way to guarantee that changing of response status can be done. The logic is with the application server, not necessarily with Magnolia, thus we can never guarantee it (apart from totally killing writing to the response and creating unlimited buffer, which would make the server vulnerable to resource starvation and would also kill the TTFB performance).
For those reasons, we are closing this ticket.
|