discord-api-docs icon indicating copy to clipboard operation
discord-api-docs copied to clipboard

PATCHing with CV2 breaks media uploads

Open VelvetToroyashi opened this issue 7 months ago • 1 comments

Description

As it stands right now, attempting to defer or otherwise edit a media gallery into a message throws a 400 and claims the unfurled media attachment is not found

This also happens when attempting to use the legacy followup as an edit method, but does not occur when using a direct response or a separate followup

Steps to Reproduce

As some psudocode of what does and does not work:

// Assume that 'builder' contains the following:
// 1 file (`image.png`)
// 1 Media gallery & item referenced via `attachment://image.png`

// Does NOT work; undocumented behavior for followup = patch
await interaction.DeferAsync();
await interaction.FollowupAsync(builder); // 400

// Does NOT work (expected behavior: message is edited and media gallery is shown
await interaction.RespondAsync(new TextDisplayComponent("Hello!")); 
await interaction.EditOriginalResponseAsync(builder); // 400! Happens even when initial response is cv2

// DOES work as expected
await interaction.RespondAsync(builder); // Initial response

// DOES work as expected
await interaction.CreateResponseAsync(new TextDisplayComponent("Hello!"));
await interaction.FollowupAsync(builder); // Seperate response; attachment is posted as expected

This appears to be specific to media galleries as uploading attachments normally works fine

Expected Behavior

The media gallery appears as normal

Current Behavior

The following 400 is returned

{"components":{"0":{"items":{"0":{"media":{"url":{"_errors":[{"code":"UNFURLED_MEDIA_ITEM_REFERENCED_ATTACHMENT_NOT_FOUND","message":"The referenced attachment (\u0022attachment://image.webp\u0022) was not found"}]}}}}}}}

Screenshots/Videos

No response

Client and System Information

N/A; API V10

VelvetToroyashi avatar Apr 28 '25 13:04 VelvetToroyashi

This issue also happens for messages sent via channels, I can reproduce it when the attachments field is absent from the PATCH request, sending even an empty array is enough to fix the issue.

The documentation says "only files listed in the attachments parameter will be appended to the message", but as I said, there is no issue sending an empty array while still having the attachments in the form data

freya022 avatar Apr 30 '25 17:04 freya022