Extraneous space on editing an empty report-variable macro

  • 4
  • Problem
  • Updated 2 years ago
We are using the report-variable macro's "default" parameter as a means to create a simple, concise conditional, wherein if the key chain injected in the "value" parameter returns a valid result, the variable is set to that, but if it returns null, then the key chain injected in the "default" parameter is used, instead.  This works well.

However, this fails and logs an error if there is any content in the body of the report-variable macro.  The Confluence editor seems to always want to set an otherwise-empty macro body to a single non-breaking space (ASCII/Unicode 160).  We have found that we can suppress this by editing the storage format for the report-variable macro body to:

<ac:rich-text-body><!-- --></ac:rich-text-body>

That is, the opening and closing tags for the body need to be on the same line, with only an XML comment containing a single space.  Unfortunately, the next time the template is edited, it goes right back to the non-breaking space.

I don't know what it would take to get Atlassian to fix the editor to not do this, or what side effects there might be.  Would it be possible to get the report-variable macro to just ignore the single non-breaking space in the macro body, or maybe even any string of whitespace?

Thanks!

-Brandon :)
Photo of Brandon Ibach

Brandon Ibach

  • 12 Posts
  • 4 Reply Likes

Posted 3 years ago

  • 4
Photo of Nurhana Ziana Bt. Hanafi

Nurhana Ziana Bt. Hanafi, Employee

  • 3500 Posts
  • 269 Reply Likes
Hello Brandon,

Perhaps could you share below details:
- your current Confluence and Reporting plugin versions
- storage format of your Reporting page having this issue (Tools > View Storage Format)
- screenshot(s) of the error


Thanks&Regards,
Ziana
Photo of Brandon Ibach

Brandon Ibach

  • 12 Posts
  • 4 Reply Likes
Hi, Ziana...

Thanks for the quick reply.  We are on Confluence 5.2.5 and Reporting 4.2.3.

Following is a simple example of the problem.  The "text:find" and following is there to make sure we get a null value if the excerpt is empty, such that the report-variable will fail over to the default.
<ac:macro ac:name="report-variable">
  <ac:parameter ac:name="default">%page:title%</ac:parameter>
  <ac:parameter ac:name="name">description</ac:parameter>
  <ac:parameter ac:name="value">%page:excerpt &gt; text:find ".+" &gt; first &gt; match:value%</ac:parameter>
  <ac:parameter ac:name="atlassian-macro-output-type">BLOCK</ac:parameter>
  <ac:rich-text-body>
    <p> </p>
  </ac:rich-text-body>
</ac:macro>
<p>Description of this page: <ac:macro ac:name="report-info">
    <ac:parameter ac:name="link">true</ac:parameter>
    <ac:default-parameter>variable:description</ac:default-parameter>
  </ac:macro>
</p>
This causes the following error (trimmed to a reasonable length - I can provide the full stack if really needed).
[INFO] [talledLocalContainer] 2014-12-30 10:17:32,993 WARN [http-1990-1] [confluence.macro.display.ReportVariableMacro] executeVerified Error while reporting on "/confluence/pages/viewpage.action?title=Report+Variable+Test&spaceKey=PTS": <p>á</p>[INFO] [talledLocalContainer] net.customware.reporting.core.ReportException: <p>á</p>
[INFO] [talledLocalContainer]   at net.customware.reporting.confluence.macro.display.ReportVariableMacro.getValue(ReportVariableMacro.java:94)
[INFO] [talledLocalContainer]   at net.customware.reporting.confluence.macro.display.ReportVariableMacro.report(ReportVariableMacro.java:117)
[INFO] [talledLocalContainer]   at net.customware.reporting.confluence.macro.AbstractReportingMacro.executeVerified(AbstractReportingMacro.java:131)
[INFO] [talledLocalContainer]   at net.customware.reporting.confluence.license.LicensedConfluenceMacro.execute(LicensedConfluenceMacro.java:45)
[INFO] [talledLocalContainer]   at org.randombits.support.confluence.ConfluenceMacro.execute(ConfluenceMacro.java:65)
[INFO] [talledLocalContainer]   at net.customware.reporting.confluence.macro.AbstractReportingMacro.execute(AbstractReportingMacro.java:94)
[INFO] [talledLocalContainer]   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[INFO] [talledLocalContainer]   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[INFO] [talledLocalContainer]   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[INFO] [talledLocalContainer]   at java.lang.reflect.Method.invoke(Method.java:606)
[INFO] [talledLocalContainer]   at com.atlassian.confluence.macro.xhtml.XhtmlMacroManager$ResourceAwareMacroInvocationHandler.invoke(XhtmlMacroManager.java:220)
[INFO] [talledLocalContainer]   at com.sun.proxy.$Proxy1872.execute(Unknown Source)
[INFO] [talledLocalContainer]   at com.atlassian.confluence.content.render.xhtml.view.macro.ViewMacroMarshaller.marshal(ViewMacroMarshaller.java:95)
Thanks!

-Brandon :)
Photo of Nurhana Ziana Bt. Hanafi

Nurhana Ziana Bt. Hanafi, Employee

  • 3500 Posts
  • 269 Reply Likes
Hello Brandon,

Thank you for the details. I've tested and confirmed on this issue. A bug report has been created for this.


Thanks&Regards,
Ziana
Photo of Brandon Ibach

Brandon Ibach

  • 12 Posts
  • 4 Reply Likes
Hi, Ziana...

Any word on the status of this bug?  We are now on Confluence 5.8.18 and Reporting 7.2.0 and have been getting this error in our logs, though the macro appears to still be functioning correctly, despite the workaround described above.

Having investigated this issue in depth, I would be happy to help in any way I can to get this resolved as soon as possible.

Thanks!

-Brandon :)
Photo of Brandon Ibach

Brandon Ibach

  • 12 Posts
  • 4 Reply Likes
Sorry, that's Reporting 5.6.0 that we're on (7.2.0 is Scaffolding).
Photo of Stephen Gramm

Stephen Gramm

  • 154 Posts
  • 6 Reply Likes
May we know the status of the fix for this verified BUG?
Photo of Suresh Mathusuthanan

Suresh Mathusuthanan, Alum

  • 117 Posts
  • 9 Reply Likes
Hi Stephen,

Our developers have released a fix in regards to this issue since Reporting 6.4.3, please check the announcement on our ServiceRocket Community.

You can upgrade your Reporting to the latest version. Let me know if this is working on your end.

Thank you.

Regards,
Suresh