Updating content using REST API fails with "Content body cannot be converted to new editor format"

I am in the process of building a workaround for a Confluence bug where relative links inside page trees don’t get updated when using the Copy Page Hierarchy REST endpoint, but rather point back to the original page tree.

For the workaround, I am manually updating the links by using a PUT request, to which I supply the updated content in storage format. I have discovered that this request often fails, with the following error message:

{"statusCode":400,"data":{"authorized":false,"valid":true,"errors":[],"successful":false},"message":"com.atlassian.confluence.api.service.exceptions.BadRequestException: Content body cannot be converted to new editor format"}

Here is an example how to reproduce the issue:

  1. Create a Confluence page with a link to another page, without specifying a custom link text:
  2. Try to update the page using the REST API, providing its unmodified content:
fetch('https://cdauth.atlassian.net/wiki/rest/api/content/1459650708', {
    method: 'put',
    headers: { 'Content-type': 'application/json' },
    body: JSON.stringify({
        id: "1459650708",
        type: "page",
        title:"asdf2 Page 5",
        body: {
            storage: {
                value: "<p><ac:link ac:card-appearance=\"inline\"><ri:page ri:content-title=\"asdf2 Page 4\" ri:version-at-save=\"15\" /><ac:link-body>asdf2 Page 4</ac:link-body></ac:link> </p>",
                representation: "storage"
            }
        },
        version: {
            number: 2
        }
    })
}).then((res) => res.json()).then((res) => console.log(res))

The page can be edited without problems, but it cannot be updated using the REST endpoint with the storage format, at least as long as the link remains part of the page content.

The error only occurs with certain items in the page content. Removing the link from the above page makes the error go away.

I cannot think of a good workaround for this problem.

6 Likes

@candid - investigating with the Confluence Cloud team (also updated the DEVHELP ticket you filed)

2 Likes

@candid - initial investigation may have uncovered a bug which is being dug into further by the editor team. It appears that inside the ri:page tag there’s a missing ri:space-key attribute, which happens when you paste a page link that’s in the same hierarchy/tree.

That’s just an initial finding… but lets see what the team comes up with.

3 Likes

We have seen similar issues with saving back the exact storage format handed to us failing.

1 Like

Thanks Neil.
We noticed this a while back and opened DEVHELP-4183. I opened it as a P4 so it hasn’t gotten attention yet (can’t remember why I didn’t use P3… maybe I just slipped on the dropdown input :slight_smile: ).

In any case, in our reproducer we use cph to create a new copy of a page, edit/publish, then edit a 2nd time and that is when it says “Page has been converted…”. and then the page is not editable again.

We have an internal bug we are using to track this and can watch this thread but if someone could pickup our DEVHELP and group it w/ the others that would help too because our whole team has eyes on that for notifications.

Thanks!

Any date for the fix? really annoying bug, we’re stuck!

1 Like

@nmansilla: My understanding is that ri:page tags contain the ri:space-key attribute only if the referenced page is in a different space. This is at least how all instances of the storage format that I have encountered both on Cloud and Server were formatted. So if the bug is related to that, I would say that the problem is not that the ri:space-key attribute is missing, but rather that some part of the code is not handling a missing ri:space-key attribute properly.

1 Like

Hello,

Just FYI, this issue has been reported in the Atlassian Community as well and I have created the below bug ticket to have it addressed:

You can set yourself as a watcher of a above ticket in order to be notified in case of any progress.

Cheers,
Dario

1 Like