Return more specific errors for invalid form body sent to Create/Modify message endpoint

(#3760) Feature Under consideration api

Current problem

When making a POST/PATCH request to the /channels/{channel_id}/messages/{message_id} with invalid payload, the API only returns a generic INVALID_FORM_BODY error with no specific information about what it is that was wrong about the request:
{"code":"INVALID_FORM_BODY","message":"Invalid form body.","errors":[{"path":"message_data","message":"Invalid message data.","code":"INVALID_MESSAGE_DATA"}]}
This is in contrast to Discord API that will give a more specific error and point you at the key in the payload that's wrong.

Proposed change

I'd like Fluxer to be more specific about what was wrong about the payload sent to the Create/Modify message endpoint.

Platform

API

Additional information

Here's a few examples from Discord API:
  1. Request body:
    {"content": "text", "embeds": [{"description": "text", "author": "wrong type"}]}
    Response body:```json{"message": "Invalid Form Body","code": 50035,"errors": {"embeds": {"0": {"author": {"_errors": [{"code": "MODEL_TYPE_CONVERT","message": "Expected an object/dictionary."}]}}}}}```
  2. Request body:
    {"content": "text", "embeds": 123}
    Response body:```json{"message": "Invalid Form Body","code": 50035,"errors": {"embeds": {"_errors": [{"code": "LIST_TYPE_CONVERT","message": "Only iterables may be used in a ListType"}]}}}```
  3. Request body:
    {"content": "text", "tts": 123}
    Response body:```json{"message": "Invalid Form Body","code": 50035,"errors": {"tts": {"_errors": [{"code": "BOOLEAN_TYPE_CONVERT","message": "Must be either true or false."}]}}}```

Comments

Sign in with Fluxer to comment and vote.

No comments yet.