[MGNLPN-682] Removing a variant on a copied or imported page fails. Created: 28/Jul/22  Updated: 16/Oct/23

Status: Open
Project: Magnolia Personalization
Component/s: None
Affects Version/s: 2.1.3
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Rico Jansen Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Problem/Incident
Relates
relates to MGNLPN-700 Removing all variants from a page doe... Open
relates to MGNLPN-710 Delete all variants action fails when... Open
causality
caused by MGNLPN-560 Further Improve performance of Varian... 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:
Visible to:
Mathijn Elhorst, Michiel Meeuwissen, Tim Molenaar
Epic Link: AuthorX Support
Team: AuthorX

 Description   

Steps to reproduce

  1. Create a page with component variants on them.
  2. Copy the page
  3. On the copy try to remove a variant
Caused by: java.lang.IllegalStateException: Encountered more unregistrations than registration for the same parent page with id: e1ec6a69-40ea-4583-95e1-18a7ccd5be3f
        at info.magnolia.personalization.variant.PersonalizedPages.unregisterParentPage(PersonalizedPages.java:121) ~[magnolia-personalization-core-2.1.3.jar:?]
        at info.magnolia.personalization.variant.PersonalizedPages.unregisterNodeWithVariants(PersonalizedPages.java:113) ~[magnolia-personalization-core-2.1.3.jar:?]
        at info.magnolia.personalization.variant.BaseVariantManager.removeHasVariantMixin(BaseVariantManager.java:76) ~[magnolia-personalization-core-2.1.3.jar:?]
        at info.magnolia.personalization.variant.BaseVariantManager.deleteVariant(BaseVariantManager.java:59) ~[magnolia-personalization-core-2.1.3.jar:?]
        at com.machinezoo.noexception.CheckedExceptionHandler$CheckedConsumer.accept(CheckedExceptionHandler.java:313) ~[noexception-1.4.4.jar:?]
        at java.lang.Iterable.forEach(Iterable.java:75) ~[?:1.8.0_301]
        at info.magnolia.pages.app.detail.action.DeleteElementVariantAction.lambda$execute$0(DeleteElementVariantAction.java:57) ~[magnolia-personalization-pages-2.1.3.jar:?]
        at com.machinezoo.noexception.CheckedExceptionHandler$CheckedConsumer.accept(CheckedExceptionHandler.java:313) ~[noexception-1.4.4.jar:?]
        at java.util.Optional.ifPresent(Optional.java:159) ~[?:1.8.0_301]
        at info.magnolia.pages.app.detail.action.DeleteElementVariantAction.execute(DeleteElementVariantAction.java:51) ~[magnolia-personalization-pages-2.1.3.jar:?]
        at info.magnolia.ui.api.action.AbstractActionExecutor.execute(AbstractActionExecutor.java:62) ~[magnolia-ui-api-6.2.21.jar:?]
        ... 165 more
 

 

Expected results

The variant is removed.

Actual results

An exception is thrown and shown in the UI.

Workaround

Restart the magnolia instance.

Development notes

This problem is caused by info.magnolia.personalization.variant.PersonalizedPages

The cache it maintains does not notice when pages with personalization are created in the website that do not go through the addVariant code of the VariantManager.

As both copying as importing don't do that, the cache gets inconsistent and does not register the page. This causes unregisterParentPage(Node node) to fail, because it uses 0 for a page that actually has variants but is not in the cache.

It would be better to recheck if the page actually has variants or not in that case.

 


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