Edit mode loads stale macro context after the context has been updated

The following steps reproduce an issue which impacts Confluence user experience and prohibits implementing key functionality when developing macros. The bug produces old, stale macros which are momentarily rendered when they should not be.

  1. Create a basic connect app which includes the following Dynamic Content Macro. This test macro includes a parameter to more closely recreate what would happen with an actual production app macro.
"key": "bananamacro",
"name": {
"value": "Banana"
"url": "/macro/banana.html",
"description": {
"value": "Yellow banana"
"outputType": "block",
"bodyType": "none",
"parameters": [
"identifier": "param1",
"name": {
"value": "Test Parameter"
"description": {
"value": "A test parameter"
"type": "string",
"required": true
  1. Use the following for banana.html, which includes a crude but simple script to render based on the parameter data:
<!DOCTYPE html>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Cache-control" content="no-cache,no-store">
<script src="https://connect-cdn.atl-paas.net/all.js" type="text/javascript"></script>
let macroDataPromise = new Promise((resolve) => {
window.AP.confluence.getMacroData(function (macroData) {
macroDataPromise.then((macroData) => {
document.getElementById('banana-container').innerHTML = macroData.param1
<p id="banana-container" class="inline-paragraph">
  1. Insert the macro into a Confluence page, with some test text in the parameter input field
  2. Save the macro (let’s call this ‘macro state A’)
  3. Observe the rendered content, which is based on the parameter value
  4. Publish the page
  5. Edit the page
  6. Edit the macro and change the parameter to a different text value
  7. Save the macro (let’s call this ‘macro state B’) and publish the page
  8. Edit the page and observe what is rendered

Expected result
The macro is rendered with macro state B

Actual result
The macro is rendered with ‘macro state A’ briefly, before being replace with ‘macro state B’

When the macro is rendered with ‘macro state A’, the entire macro code is run with the old, obsolete context. If we consider this behaviour occurring in a production application’s macro, then depending on what your macro does exactly, I believe this could result in anything from an annoying visual bug to potentially a legitimate security concern.

The entire macro code is run when this ‘phantom macro’ is rendered, using the old context, meaning erroneous side effects (sentry calls, analytic collections, Confluence AP Events) are produced. Since AP Events are produced, this severely impacts the usefulness of that feature - it’s difficult or impossible to code around this as your code does not expect these events.

1 Like

Note that another way to reproduce the same behaviour is the following (with the banana macro listed above)

  1. Insert the banana macro onto a blank confluence page
  2. Save the macro and publish the page
  3. Edit the page
  4. Delete the macro
  5. Publish the page
  6. Edit the page

Expected result
A blank page appears in the editor

Actual result
The macro which you previously deleted is rendered briefly before disappearing. All of the macro’s code executes.


@TonyGoughAdaptavist Also opened a similar report yesterday: Edits to checkboxes do not update req.context . I’m not sure if are observing the same issue, though.

1 Like

Thanks for replying Marc, after looking at this I do believe it is the same behaviour, which shows it affects not only iframe macros. If you try my reproduction steps but with the checkbox:

  1. Insert a checkbox ([]) onto a confluence page
  2. Publish the page
  3. Edit the page
  4. Delete the checkbox
  5. Publish the page
  6. Edit the page

You will briefly see the checkbox being rendered before disappearing.

We believe the underlying issue is going to be related to graphql on Confluence’s side, perhaps related to cache and how they load content for the editor.


@dmorrow Can Atlassian have a look at the current thread and Edits to checkboxes do not update req.context ? I can also open a ticket if preferred.

1 Like

Hi @marc and @TonyGoughAdaptavist ,

Thanks for explaining the issue with such clarity. I’ve created CONFCLOUD-71216 for the rendering of stale macro data.

@marc, perhaps you can create the issue for the checkboxes problem.