[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: PNG File screenshot11.png     PNG File screenshot22.png    
Issue Links:
dependency
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:
          [@cms.area name="main"/]

           Save template.

  • Go to Pages app and create a page with the Basic template (name it "Test" for example)
  • When you open the Page to edit, you will see this EXPECTED_PAGE_TAG error and the areas not rendered correctly. See screenshot11. 

Expected results

Not to see this error when I edit page in the Pages app.

Actual results

Error shown in screenshot11. There is an error message and no green bars for areas available.

Workaround

None 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.

 

Generated at Mon Feb 12 04:30:47 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.