Received value of X-Audit-Log-Reason header is not url-decoded

(#301) Bug Confirmed api moderation

Summary

I wanted to make an action and provide an audit log reason that contains a Unicode character (✰ to be exact). Since the header value cannot contain non-ISO-8859-1 characters (or, realistically, characters outside the US-ASCII charset), I provided a URL-encoded UTF-8 value to the X-Audit-Log-Reason header, expecting the API to decode it before storing. Instead, the value was stored as is. FYI, this works fine on Discord.

Steps to reproduce

  1. Make the following API request:
    POST /v1/guilds/{guild.id}/roles HTTP/1.1
    Authorization: Bot {token}
    X-Audit-Log-Reason: %28example%29 %E2%9C%B0
    Content-Type: application/json
    Host: api.fluxer.app
    Content-Length: 17
    
    {"name": "repro"}
    
  2. Look at the audit log in the client to see the issue. You can also verify the value of the "reason" field for the audit log entry in DevTools to see that the reason was not decoded before storing.
FYI, the value of the reason before encoding in the above request is:
(example) ✰

Environment (optional)

N/A

Logs or screenshots (optional)

image
  • 553801626-e97a567c-dc62-4145-b28d-14ebc5b4b786.png

    553801626-e97a567c-dc62-4145-b28d-14ebc5b4b786.png

    2545×971 | 567 kB

2 comments

Sign in with Fluxer to comment and vote.
Comment by Rex
RexSystem 1 vote
Status changed from Fixed to Confirmed
Reopened because the reporter says the API still returns the reason URL-encoded.
Comment by @Jackenmen
RexSystem 1 vote originally by @Jackenmen on GitHub OP
This seems to be resolved in at least one definition of resolved. As in, the canary UI shows it correctly, but the reason field in API responses remains URL-encoded. I'm not sure whether that's the expected behaviour, it doesn't seem ideal from the API user's perspective and it differs from how Discord does it. image
  • 608897919-3a891110-eeee-4f9e-82ee-518e5279eb5c.png

    608897919-3a891110-eeee-4f9e-82ee-518e5279eb5c.png

    2545×946 | 457 kB