Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-25280

Notifications macro fails with "Unsupported block node [null]" when there is no notification preference

    XMLWordPrintable

Details

    • Unit
    • Unknown
    • N/A
    • N/A

    Description

      Steps to reproduce

      1. Create a page containing {{{ notifications useUserPreferences="true" / }}}
      2. View that page as guest (or as a user who has no notification preference enabled)

      Expected

      The macro displays no notification.

      Actual

      The asynchronous rendering of the notifications fails, and the following error is logged:

      ERROR o.x.r.a.i.AsyncRendererJob - Exception thrown during job execution
      org.xwiki.rendering.RenderingException: Error while retrieving the notification
      	at org.xwiki.notifications.notifiers.internal.DefaultAsyncNotificationRenderer.render(DefaultAsyncNotificationRenderer.java:125)
      ...
      Caused by: org.xwiki.notifications.NotificationException: Fail to get the list of notifications.
      	at org.xwiki.notifications.sources.internal.DefaultParametrizedNotificationManager.getRawEvents(DefaultParametrizedNotificationManager.java:159)
      ...
      Caused by: org.xwiki.eventstream.EventStreamException: Unsupported block node [null]
      	at org.xwiki.notifications.sources.internal.ExpressionNodeToEventQueryConverter.parseBlock(ExpressionNodeToEventQueryConverter.java:121)
      	at org.xwiki.notifications.sources.internal.ExpressionNodeToEventQueryConverter.parse(ExpressionNodeToEventQueryConverter.java:107)
      	at org.xwiki.notifications.sources.internal.EventQueryGenerator.generateQuery(EventQueryGenerator.java:55)
      	at org.xwiki.notifications.sources.internal.EventSearcher.searchStoreEvents(EventSearcher.java:91)
      	at org.xwiki.notifications.sources.internal.EventSearcher.searchEvents(EventSearcher.java:74)
      

      Analysis

      QueryExpressionGenerator#generateQueryExpression returns null when the notification parameters have no preference (which is the case for the guest user with useUserPreferences=true, since no preference can be loaded without a user), meaning that no event can match. EventQueryGenerator#generateQuery passes this null expression to ExpressionNodeToEventQueryConverter#parse, which throws.

      Before XWIKI-19826 the exception of the event store was caught and the search fell back on the legacy event stream, which returned an empty list for a null query. Since the fallback was removed, the case is not handled anymore.

      Found in the logs of NotificationsIT#compositeNotifications on CI (the test ends on a page with the notifications macro using the user preferences, and its tear down removes the users).

      Attachments

        Issue Links

          Activity

            People

              surli Simon Urli
              surli Simon Urli
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: