[MAGNOLIA-8856] Page is not available via full JCR path if handlePrefix has more than 1 level Created: 24/Mar/23  Updated: 18/Apr/23  Resolved: 13/Apr/23

Status: Closed
Project: Magnolia
Component/s: None
Affects Version/s: 6.2.30
Fix Version/s: None

Type: Bug Priority: Neutral
Reporter: Carlos Cantalapiedra Assignee: Oanh Thai Hoang
Resolution: Not an issue Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: 2d 2.5h
Original Estimate: Not Specified

Issue Links:
Problem/Incident
duplicate
duplicates MAGNOLIA-8855 Page is not available via full JCR pa... Closed
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
Work Started:

 Description   

Issue description

Following page 
https://demoauthor.magnolia-cms.com/.magnolia/admincentral#app:pages-app:browser;/travel/about/company::

is reachable via the following 2 URLs with the handlePrefix set to /travel
https://travel-demo.magnolia-cms.com/about/company
https://travel-demo.magnolia-cms.com/travel/about/company

If the handlePrefix is changed to /travel/about, the second URL with the full path to the node returns a 404, as the handlePrefix is added to the URL.

Link to the handlePrefix
https://demoauthor.magnolia-cms.com/.magnolia/admincentral#app:site:browser;/travel/mappings/website@handlePrefix:null:

handlePrefix with /travel/about

Works:[ https://travel-demo.magnolia-cms.com/company|https://travel-demo.magnolia-cms.com/company]
Error: https://travel-demo.magnolia-cms.com/travel/about/company

The problem is in info.magnolia.cms.beans.config.URI2RepositoryMapping#getHandle, as only the part before the first "/" is compared with the handlePrefix and the following removal of the handlePrefix isn't done.

Expected results

The page can be accessed through the full path https://travel-demo.magnolia-cms.com/travel/about/company

Actual results

404 error is shown at browser

Workaround

Modify the getHandle() method within the URI2RepositoryMapping class to get the handle before first slash as follows:

URI2RepositoryMapping#getHandle()
[...]
if (StringUtils.startswith(cleanedUri, StringUtils.prependIfMissing(handlePrefix, "/"))) {       
 // We remove any occurrences of the handle prefix from given URI        
cleanedUri = StringUtils.removeStart(cleanedUri, handlePrefix);
}

Development notes

N/A



 Comments   
Comment by Carlos Cantalapiedra [ 24/Mar/23 ]

Support score: 5 (bug) + 2 (MIPA) + 5 (very common interest) + 5 (quick win) + 5 (latest major release) + 0 (no threat) + 0 (no blocker) = 22

Comment by Jaroslav Simak [ 11/Apr/23 ]

Thank you very much oanh.thai. I agree with you that this is not a bug, it is expected behavior when handlePrefix property is configured.

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