Jira Gadgets fail to load in Confluence with a "Error rendering macro 'gadget'" error

Still need help?

The Atlassian Community is here for you.

Ask the community


Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

Jira Gadgets are not working in Confluence with the following error:

Error in text format
Error rendering macro 'gadget'

The gadget at http://charlie.atlassian.net/rest/gadgets/1.0/g/com.pyxis.greenhopper.jira:greenhopper-gadget-sprint-health/gadgets/greenhopper-sprint-health.xml was not added to this Confluence instance yet.

The Sprint Health Gadget was used as an example here, but other Jira Gadgets can be affected the same way.

Environment

Confluence Server and Data Center.

Diagnosis

  1. There is a valid Application Link connecting Confluence and Jira.
  2. Jira is registered in Confluence as an External Gadget Feed.
  3. The error mentions a URL that does not match Jira's current Base URL.

Cause

The Jira server or data center 'base URL' has changed (possibly due to a migration) but the macro references were not updated to the new URL in Confluence.

Solution

Update the affected macros with a valid 'base URL' so it points to the current Jira server or data center instance.

Option 1 - Source Editor

If only a handful of macros need to be fixed, using the Confluence Source Editor* app is the quickest and safest approach.

Although the Marketplace page mentions the Confluence Source Editor is for Confluence Server only, it can be installed in Confluence Data Center instances and should work as well.

In order to do that:

  1. Install the Confluence Source Editor app in your Confluence server/data center.
  2. Navigate to the affected page and select Edit at the top of the page.
  3. Select the Open in source editor button ('<>' symbol in the upper-right corner).
  4. Locate the <ac:parameter ac:name="url"> parameter.
  5. Replace the invalid URL with the correct one. For the example, we should replace 'charlie.atlassian.net' with a new URL that points to the correct Jira Server/Data Center endpoint.
  6. Click Apply then Update
  7. Refresh the page.

Here's an example of how the Sprint Health Gadget looks in Storage Format:

<p>
  <ac:structured-macro ac:macro-id="a1523271-9080-40f9-8c0f-aa234f7f0b0e" ac:name="gadget" ac:schema-version="1">
    <ac:parameter ac:name="preferences">rapidViewId=1&showRapidViewName=true&sprintId=1&showSprintName=true&showAssignees=false&isConfigured=true&refresh=15&=false</ac:parameter>
    <ac:parameter ac:name="url">http://charlie.atlassian.net/rest/gadgets/1.0/g/com.pyxis.greenhopper.jira:greenhopper-gadget-sprint-health/gadgets/greenhopper-sprint-health.xml</ac:parameter>
  </ac:structured-macro>
</p>

Option 2 - Database Manipulation

Find-Replace operation

A 'Find-Replace' operation on the database may be necessary if several macros need to be fixed.

Make sure to back up your database before performing any changes! We strongly recommend testing this approach on a testing or staging environment before implementing the changes in production!

To change the URL in the database to another URL:

  1. Stop Confluence.
  2. Create a backup of Confluence's database. Save somewhere offsite for safekeeping.
  3. Run the following SQL query on Confluence's database:

    UPDATE BODYCONTENT 
    SET body = replace(body,'old-url','new-url') 
    WHERE body LIKE '%old-url%';
  4. Verify that the bodycontent table now has the new url.
  5. Start Confluence.

Specific URL reference

In order to change Macro references only, we suggest using a more targeted UPDATE statement. For instance, in step 3 above, use this SQL UPDATE statement instead:

UPDATE BODYCONTENT
SET body = replace(body,'<ac:parameter ac:name="url">http://charlie.atlassian.net','<ac:parameter ac:name="url">http://jira.charlie.com')
WHERE body LIKE '%<ac:parameter ac:name="url">http://charlie.atlassian.net%';

(info) This will replace http://charlie.atlassian.net with http://jira.charlie.com

Using the UPDATE statements will replace ALL references to the old URL, including plain-text entries in Pages, Comments and Blog posts in the database. 

Last modified on Jan 5, 2023

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.