Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-100255

Popular Labels macro resulted in 500 Internal Server Error on REST API request for Page Body

XMLWordPrintable

      Issue Summary

      Popular Labels macro with non-existing space parameter can cause 500 Internal Server Error on REST API request for Page Body.

      Version info

      Replicable in:

      • Confluence 7.8.0
      • Confluence 9.2.5
      • Confluence 9.5.2

      Not Replicable in:

      • Confluence 7.7.4 and earlier

      Steps to Reproduce

      1. Install Confluence 7.8.0 or above
        This issue has been tested and confirmed still impacting Confluence 9.2.5
      2. Create a Page, and insert a Popular Labels macro
      3. Edit the Popular Labels macro
        • In "Restrict Labels to this Space Key" column, enter a Space that does not exist
          Despite the search field return "Not found", the macro can still be saved with a non-existing Space name
      4. At this point, you'd have a Storage Format that looks like this:
        <ac:structured-macro ac:name="popular-labels" ac:schema-version="1" ac:macro-id="2af6be0c-b801-427f-8d39-949cdc390aba">
        <ac:parameter ac:name="spaceKey">
        <ri:space ri:space-key="abc" />
        </ac:parameter>
        </ac:structured-macro>
        

        "abc" space key does not exist in the Confluence

      5. Save the macro, and publish the page.
        • A meaningful error message will be displayed on the page's View Mode:

          Error rendering macro 'popular-labels'. A space with 'abc' key does not exist

      6. Use REST API to retrieve the Page Body with either of the expand below that would render the page into HTML format:
        • body.view
        • body.export_view
        • body.styled_view
        • body.anonymous_export_view
          Example
          curl -u username:password "<Confluence_Base_URL>/rest/api/content/<Page_ID>?expand=body.view"
          

      Expected Results

      REST API request respond with the rendered page content.

      Actual Results

      The REST API request responded with 500 Internal Server Error.

      curl -u admin:admin "http://localhost:6952/c952/rest/api/content/163926?expand=body.view"
      
      {"statusCode":500,"message":"","reason":"Internal Server Error"}
      

      The below exception is thrown in the atlassian-confluence.log file:

      2025-07-14 16:58:53,286 ERROR [http-nio-6952-exec-10 url: /c952/rest/api/content/163926; user: admin] [xhtml.view.macro.ViewMacroMarshaller] handleMacroExecutionException Error rendering macro: popular-labels
       -- url: /c952/rest/api/content/163926 | userName: admin | contentId: ContentId{id=163926} | traceId: e258037bbe64d87d
      java.lang.RuntimeException: A space with 'abc' key does not exist
      	at com.atlassian.confluence.impl.labels.adaptivelabelcache.dao.DatabaseBasedAdaptiveLabelCacheDaoImpl.getSpaceIdByKey(DatabaseBasedAdaptiveLabelCacheDaoImpl.java:122)
      	at jdk.internal.reflect.GeneratedMethodAccessor1646.invoke(Unknown Source)
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
      	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:359)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:196)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
      	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:380)
      	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
      	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:223)
      	at jdk.proxy4/jdk.proxy4.$Proxy404.getSpaceIdByKey(Unknown Source)
      	at com.atlassian.confluence.impl.labels.adaptivelabelcache.AdaptiveMostUsedLabelsCacheImpl.getSpaceRecord(AdaptiveMostUsedLabelsCacheImpl.java:147)
      	at com.atlassian.confluence.impl.labels.CachingLabelManager.getMostPopularLabelsInSpaceLite(CachingLabelManager.java:526)
      	at jdk.internal.reflect.GeneratedMethodAccessor1426.invoke(Unknown Source)
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
      	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:359)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:196)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
      	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:380)
      	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
      	at org.springframework.retry.annotation.AnnotationAwareRetryOperationsInterceptor.invoke(AnnotationAwareRetryOperationsInterceptor.java:165)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
      	at com.atlassian.spring.interceptors.SpringProfilingInterceptor.invoke(SpringProfilingInterceptor.java:16)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
      	at com.atlassian.confluence.util.profiling.ConfluenceMonitoringMethodInterceptor.invoke(ConfluenceMonitoringMethodInterceptor.java:36)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
      	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:223)
      	at jdk.proxy4/jdk.proxy4.$Proxy436.getMostPopularLabelsInSpaceLite(Unknown Source)
      	at jdk.internal.reflect.GeneratedMethodAccessor1426.invoke(Unknown Source)
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
      	at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:26)
      	at jdk.proxy4/jdk.proxy4.$Proxy788.getMostPopularLabelsInSpaceLite(Unknown Source)
      	at jdk.internal.reflect.GeneratedMethodAccessor1426.invoke(Unknown Source)
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
      ...
      

      The same error will also be thrown when the page is loaded in a Browser, but the UI provides a meaningful error and load the rest of the page correctly.

      Workaround

      Currently there is no known workaround for this behavior for the impacted expand. A workaround will be added here when available
      expand=body.storage on the other hand, is not impacted. Because the Popular Labels macro is not rendered, but shown as Storage Format instead.

        1. actual result.png
          actual result.png
          810 kB
        2. expected result.png
          expected result.png
          607 kB

              ttranminh Tam Tran
              btan@atlassian.com Damien Tan
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: