Unable to saveMacro in Confluence Cloud after migration from Confluence Server

Hi,

I have an app (sort of a spreadsheet) that creates attachments to pages.
I’m trying to modify the macro parameters of an attachment after a migration from Confluence Server to Confluence Cloud.

Server
The macro parameters of my attachment on Server - before migrating - look like this:
<p> <ac:structured-macro ac:name="spreadsheets" ac:schema-version="1" ac:macro-id="819bee31-0b70-4f8a-bc71-ab8a9ab41887"> <ac:parameter ac:name="containerType">page</ac:parameter> <ac:parameter ac:name="documentId">Migration.ssc</ac:parameter> <ac:parameter ac:name="containerId">786433</ac:parameter> <ac:parameter ac:name="documentTitle" /> <ac:parameter ac:name="title">Migration</ac:parameter> </ac:structured-macro> \</p>

Cloud
Macro parameters on Confluence Cloud have a different structure. This is an exemple of an attachment created directly on Cloud (no migration):
<ac:structured-macro ac:name="spreadsheets" ac:schema-version="1" data-layout="default" ac:local-id="64a4834f-3cb5-4b26-acee-c4bd41412870" ac:macro-id="0783af5a-4f4c-4a9d-98a2-d4b17d62c293"> <ac:parameter ac:name="storageType">attachment</ac:parameter> <ac:parameter ac:name="attachmentId">att17629778</ac:parameter> <ac:parameter ac:name="containerId">17727928</ac:parameter> <ac:parameter ac:name="displayRatio">FIXED_WIDTH</ac:parameter> <ac:parameter ac:name="timestamp">1651177276374</ac:parameter> <ac:parameter ac:name="storageId">new.ssc</ac:parameter> </ac:structured-macro>

We can notice a few differencies but the two work on their own platform (Server and Cloud). The most important thing to retain is that there is no attachmentId on Server, but there is on Cloud.

After migration
The issue I have concerns migration from Server to Cloud. After migrating to Cloud, the macro parameters are still the ones from Server (without attachmentId). What I want to do is modify these macro Parameters on Cloud to store the attachmentId and align with Cloud’s behaviour.

However, when I do AP.confluence.saveMacro({...macroParameters, attachmentId}, I get an error from the Confluence API:

Confluence documentation on the saveMacro endpoint isn’t that helpful: Confluence

Does anyone have a lead to fix this issue ?

3 Likes

Hi @FranoisBillet,

To clarify, is this only happening for the migrated tenants?
When you call AP.confluence.saveMacro({...macroParameters, attachmentId} for new cloud tenants, does the same error happen?

For debugging purposes, can you share a simple space export with this issue happening?

Hey @EnginTekin,
Thank you for your response.

Indeed, for non-migrated Cloud instances, the same error occurs in Confluence view mode. AP.confluence.saveMacro() works in Confluence edit mode (after page publication) for both non-migrated and migrated Cloud instances.

Thus the problem seems to be that it is not possible to modify macro properties in Confluence view mode, which is problematic for my migration use case. This would mean that, after a migration from Server and up until I edit my application in Confluence edit mode, I have no way to modify my application’s macro Properties. Is this a known limitation from Atlassian ?

I also noticed that, when I edit my application and call saveMacro() in Confluence edit mode, macro properties are actually modified when I publish the page.
That’s why I tried to trigger the event of a page publication in Confluence view mode to find my way around this possible limitation, but I couldn’t find any information about what event is sent when I publish a page.

Finally, and this might have a thing to do with this issue, when migrating a space from Server to Cloud, I get an error message saying “Attachments missing from the selected spaces”:
attachments_missing_error

However I didn’t delete, rename or move any of the attachments.
The CSV file indicates the file paths of the attachments and these paths do not exist in my target folder. For information, I’m starting a Confluence server with atlas-debug command.

I also get a warning pop-up before starting the migration process. (I wanted to share a screenshot but I’m limited to 1 attachment per post…)

How can I upload the zip of my Server’s space ? This editor won’t let me upload this type of extension.

Hi @FranoisBillet,

Thank you for clarifying the issue. Actually AP.confluence.saveMacro() is expected to only work in edit mode. As you noted, after AP.confluence.saveMacro(), page needs to be published for the saved state to work in view mode. Because view mode shows the last saved version of the page, and edit mode shows the current draft of the page.

Are you only changing the format of the macro parameters in view mode? I wonder if a different approach would work in this case. For example, instead of updating the macro parameters, can you handle the server configuration while rendering your macro?

Hi again,

That’s what I’m doing actually, but I wanted to do better and have the same macro parameters for both cloud instances and server migrated instances.
Thank you for confirming that this is a Confluence limitation.

Have a good day :slight_smile:

Ah I see. I know there’s a way to do updates before the migration. I’m not very familiar with this process but I believe this page covers more.
Have a nice day :slight_smile:

Hello @EnginTekin,

Thanks for the information, I’ll look into it.
You said it is not possible to use AP.confluence.saveMacro() in view mode, but is there another way to edit macro properties of an attachment in view mode ?

Hi @FranoisBillet, another way is to find all the pages that includes your macro using cql and update each page using content API. 1 downside of this is that it would add a new page version in the page history and everyone watching the page would get a notification which can be noisy.