Cogmasters/concord

HTTP_MIMEPOST and HTTP_POST should be the same value when generating a bucket key

lcsmuller opened this issue · 0 comments

Describe the bug

Because those are technically the same HTTP method, it should also be the same value when generating a bucket key. Currently Concord will generate two different buckets for the same route, leading to wrong ratelimiting handling for those buckets.

Expected behavior

Generate the same bucket key for some route using either method.

To Reproduce

The following code from @Anotra can reproduce the error, it will trigger a 429 even though we're handling ratelimiting:

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include <concord/discord.h>

#define TEST_FILE "..." // change to some file to be sent over Discord

static void
on_message_create(struct discord *client, const struct discord_message *message) {
  if (strcmp(message->content, "quit") == 0) {
    discord_shutdown(client);
  } else if (!message->author->bot) {
      discord_create_message(client, message->channel_id,
        &(struct discord_create_message) {
          .content = message->content,
        }, NULL);
      discord_create_message(client, message->channel_id,
        &(struct discord_create_message) {
          .attachments = &(struct discord_attachments) {
            .realsize = 1, .size = 1,
            .array = &(struct discord_attachment) {
              .filename = TEST_FILE,
            },
          }
        }, NULL);
  }
}

int
main() {
  struct discord *client = discord_config_init("../config.json");
  discord_add_intents(client, DISCORD_GATEWAY_MESSAGE_CONTENT);
  discord_set_on_message_create(client, on_message_create);
  discord_run(client);
  discord_cleanup(client);
}

Version

v2.1.0