[MGNLREST-757] @ancestor allows retrieving nodes regardless configured rootPath Created: 03/Oct/23  Updated: 20/Oct/23  Resolved: 18/Oct/23

Status: Closed
Project: Magnolia REST Framework
Component/s: None
Affects Version/s: 2.2.22
Fix Version/s: 3.0.0, 2.2.23

Type: Bug Priority: Neutral
Reporter: Jonathan Ayala Assignee: Anh Vu
Resolution: Fixed Votes: 0
Labels: None
Σ Remaining Estimate: 0d Remaining Estimate: 0d
Σ Time Spent: 6d 6.25h Time Spent: 6d 2.25h
Σ Original Estimate: Not Specified Original Estimate: Not Specified

Attachments: File pages.yaml    
Issue Links:
causality
Sub-Tasks:
Key
Summary
Type
Status
Assignee
MGNLREST-761 Implement Sub-task Closed Anh Vu  
MGNLREST-762 Review Sub-task Closed Oanh Thai Hoang  
MGNLREST-763 piQA Sub-task Closed Canh Nguyen  
MGNLREST-764 QA Sub-task Closed Oanh Thai Hoang  
Template:
Acceptance criteria:
Empty
Task DoD:
[X]* Doc/release notes changes? Comment present?
[X]* Downstream builds green?
[X]* Solution information and context easily available?
[X]* Tests
[X]* FixVersion filled and not yet released
[X]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:
Epic Link: Support
Sprint: DevX 48
Story Points: 2
Team: DeveloperX
Work Started:
Approved:
Yes

 Description   

Steps to reproduce

Use the attached endpoint which configures rootPath as /sportstation

  1. Request http://localhost:8080/magnoliaPublic/.rest/pages
  2. Request http://localhost:8080/magnoliaPublic/.rest/pages?@ancestor=/travel

Expected results

Nodes are returned according to the configured rootPath

  1. nodes under /sportstation are returned
  2. no nodes are returned

Actual results

Nodes are returned regardless rootPath when ancestor is set as parameter

  1. nodes under /sportstation are returned
  2. all nodes under travel are returned

Workaround

Development notes



 Comments   
Comment by Anh Vu [ 12/Oct/23 ]

Discovery output:
When the root path is configured for example root path = /sportstation and a request with @ancestor=/travel is made, behind the scenes the query has the conditions ...AND ISDESCENDANTNODE(t, [/sportstation]) AND ISDESCENDANTNODE(t, [/travel]). 

But it seems that the query involving multiple ISDESCENDANTNODE conditions with AND operator are not supported, 
only the last condition is applied and the condition for root path is ignored. (See the similar issue that people faced on stackoverflow)

The simple solution for this is that we will check if the input path for @ancestor starts with the root path, if not, a fake condition is created to make sure no nodes will be returned, for example ISDESCENDANTNODE(t, [/dummyPath]) instead of ISDESCENDANTNODE(t, [/travel]). 

Generated at Mon Feb 12 07:02:52 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.