Edit message (PATCH) endpoint does not allow for partial modifications without affecting embeds

(#606) Bug Closed: Fixed api embeds

Summary

Despite the fact that a PATCH HTTP method should apply partial modification to a resource, using the `PATCH /channels/{channel.id}/messages/{message.id}` endpoint with only "content" field results in both the message content and embeds being fully replaced by the given payload, i.e. it affects fields that weren't provided. This is unexpected for a PATCH endpoint (+ it differs from Discord's behaviour of the same endpoint). I'd only expect embeds to be removed, if "embeds": [] was included in the payload. The same problem does not seem to appear, when doing the opposite - I can edit only embeds without the content being removed. NOTE: This is a repost of #280 - I can still reproduce the issue after Fluxer V2 release.

Steps to reproduce

  1. Send the following message to the channel (`POST
/channels/{channel.id}/messages`)
{"content": "Test", "embeds": [{"description": "text"}]}
  1. See that it has content and an embed:image
  2. Edit the message created in step 1 (`PATCH
/channels/{channel.id}/messages/{message.id}`)
{"content": "edit"}
  1. See that it no longer has an embed:image
--- Note that the same issue does not occur, if instead of editing content, you were to modify the embed with the following payload in step 3:
{"embeds": [{"description": "edit"}]}
The content remains: image (side note: there's no "(edited)" indicator in such a case)

Environment

This is an API issue, so not relevant.

Logs or screenshots

Already posted above
  1. Jackuczys changed the status from Awaiting confirmation to Fixed
  1. The pull request fluxer#1199 mentions this post Closed
  2. The pull request fluxer#1199 was closed without merging Closed
  3. The pull request fluxer#1363 mentions this post Merged
  4. The pull request fluxer#1363 was merged Merged

Merged posts

These posts were merged into this one. Their comments are now part of the conversation below, marked with where they came from.

Report details

Summary

Despite the fact that a PATCH HTTP method should apply partial modification to a resource, using the `PATCH /channels/{channel.id}/messages/{message.id}` endpoint with only "content" field results in both the message content and embeds being fully replaced by the given payload, i.e. it affects fields that weren't provided. This is unexpected for a PATCH endpoint (+ it differs from Discord's behaviour of the same endpoint). I'd only expect embeds to be removed, if "embeds": [] was included in the payload. The same problem does not seem to appear, when doing the opposite - I can edit only embeds without the content being removed.

Steps to reproduce

  1. Send the following message to the channel (`POST
/channels/{channel.id}/messages`)
{"content": "Test", "embeds": [{"description": "text"}]}
  1. See that it has content and an embed:image
  2. Edit the message created in step 1 (`PATCH
/channels/{channel.id}/messages/{message.id}`)
{"content": "edit"}
  1. See that it no longer has an embed:image
--- Note that the same issue does not occur, if instead of editing content, you were to modify the embed with the following payload in step 3:
{"embeds": [{"description": "edit"}]}
The content remains: image (side note: there's no "(edited)" indicator in such a case)

5 comments

Sign in with Fluxer to comment and vote.
Comment by Rex
RexSystem 1 vote edited
Status changed from Fixed to Awaiting confirmation
This may be fixed in the current version. If it still happens for you, please say so here.
Comment by Jackuczys
Jackuczys 1 vote Merged from #280 originally by @Jackenmen on GitHub OP
I've also noticed that the loss of edited indicator is cause edited_timestamp gets set to None on such message edits.