[MGNLREST-295] Custom Reference Resolvers Failing since 2.2.2 Created: 07/Jan/21  Updated: 28/Nov/23

Status: Accepted
Project: Magnolia REST Framework
Component/s: delivery
Affects Version/s: 2.2.2, 2.2.5, 2.2.6
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Chris Jennings Assignee: Unassigned
Resolution: Unresolved Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Java Source File DummyResolver.java     Java Source File DummyWriter.java    
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:
Epic Link: Support
Team: DeveloperX

 Description   

Steps to reproduce

  1.  Configure a delivery endpoint using the attached example of a custom reference resolver.
  2.  Request content using the new endpoint.

Expected results

  1. In releases pre 2.2.2, the reference resolver works and returns a JSON serialised object.

Actual results

  1. Magnolia produces a 500 error without logging anything. In incomplete JSON response is delivered with no key for the resolved property but a serialised object.
    ie.
    {"results":[{"@name":"Testing","@path":"/Testing","@id":"bdbaf549-e1aa-4bd2-8fb9-80be4d9dc270","@nodeType":"mgnl:event", {"name":"A Dummy Object"}

Workaround

  1. None yet.

Development notes



 Comments   
Comment by Shaun Mendham [ 20/Apr/21 ]

Although not ideal, is creating a custom MessageBodyWriter class considered a viable workaround? The below has been tested and is working against Magnolia 6.2.7 and rest-content-delivery 2.2.6.

In the Dummy example this could be the corresponding Writer class: DummyWriter.java

With an entry added to dummy-module/src/main/resources/META-INF/services/javax.ws.rs.ext.Providers, referencing the writer class.

Has any other alternative been identified?

Regards,

Shaun

Comment by Chris Jennings [ 27/Apr/21 ]

Thanks very much for getting in touch, Shaun.

I validated your approach for myself (using Magnolia 6.2.8 / REST Content Delivery 2.2.6) and the output is as it was before (obviously the Jackson annotations are on the POJO are now ignored).
See: https://git.magnolia-cms.com/users/ukusergroup/repos/mug-4-20200319/browse/mug-uk-headless-examples/examples-module/src/main/java/info/magnolia/muguk/rest/delivery/jcr/v2/writers/StationWriter.java?at=MGNLREST-295
and: https://git.magnolia-cms.com/users/ukusergroup/repos/mug-4-20200319/browse/mug-uk-headless-examples/examples-module/src/main/resources/META-INF/services/javax.ws.rs.ext.Providers?at=MGNLREST-295

I raised this with czimmermann who agrees it is a bug. However, as we have a workaround, it will probably not receive much attention soon.

Comment by Shaun Mendham [ 04/May/21 ]

Thanks Chris, for validating and the update.

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