Updating Jira comment with new attachment media ID fails with ATTACHMENT_VALIDATION_ERROR

Ok so I dug into this and it’s even weirder.

If I comment out:

        commentBody.content.forEach(contentBlock => {
            if (contentBlock.type === 'mediaGroup') {
                contentBlock.content.forEach(media => {
                    if (media.type === 'media' && media.attrs.id === originalAttachmentMediaId) {
                        media.attrs.id = newAttachmentId;
                    }
                });
            }
        });

Then the code works. But here is the crazy thing, it should be the inverse. If I don’t update the comment body, then I would be submitting a comment body with an invalid media id. If I do update it, then I am submitting a valid media id.

I also double checked the above code to ensure it’s not screwing up the comment body and as far as I can tell it’s not:

INFO    17:54:01.540  22db2c72-0b01-4d45-bb57-7e6b3c5bab88  Original Comment Body:
INFO    17:54:01.541  22db2c72-0b01-4d45-bb57-7e6b3c5bab88  {"version":1,"type":"doc","content":[{"type":"mediaGroup","content":[{"type":"media","attrs":{"id":"1bf36952-f1c6-4fb7-8bfe-91bc09b5428a","type":"file","collection":""}}]},{"type":"paragraph","content":[]}]}
INFO    17:54:01.541  22db2c72-0b01-4d45-bb57-7e6b3c5bab88  Updated Comment Body:
INFO    17:54:01.541  22db2c72-0b01-4d45-bb57-7e6b3c5bab88  {"version":1,"type":"doc","content":[{"type":"mediaGroup","content":[{"type":"media","attrs":{"id":"e31953d8-0a96-435a-ac70-ec72898f7431","type":"file","collection":""}}]},{"type":"paragraph","content":[]}]}

So not sure whats going on, but seems like a problem on the Atlassian side.

ibuchanan any chance you can take a look at this?

Edit: Not sure how to strikethrough but it looks like I was getting the wrong media ID because a UUID is returned from the attachment endpoint but it’s no the right media UUID and it looked right. So continuing to dig into that, and I guess this will ultimately get resolved with an update to How to work with attachments in comments? Media vs Attachments nightmare - #3 by JulianWolf