Skip to content

400 Bad Request when exporting DMs #1419

@Adeor

Description

@Adeor

Version

v2.46.0

Flavor

CLI (Command-Line Interface)

Platform

Arch Linux (AUR)

Export format

JSON

Steps to reproduce

Run discord-chat-exporter-cli exportdm -t {token} -f Json --media --reuse-media --dateformat unixms with lots of long DM chats (30 chats, 13k total messages according to chatanalytics.app, 4.8 GB total size with media after deduping the folder with fclones)
The error is the same as in #1141 but the issue persisted over a few months (ran it once a week via a systemd service and sometimes manually for testing).
I first noticed the issue ~Q4 2024 after not using discord-chat-exporter for a while. I wiped my old disk, so I don't know which version I used before the issue occurred, but it seems more like rate-limiting, because the error consistently happens sooner when I rerun discord-chat-exporter.

Details

Error log (everything between {} are notes about what I retracted for privacy reasons):

{... works for 2-3 dms on first run, but at most 1 dm, if I rerun it instantly after the error ...}
{other user}                  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100%
{some user} ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━   0%

ERROR
DiscordChatExporter.Core.Exceptions.DiscordChatExporterException: Request to 'users/@me/channels' failed: bad request.
Response content: <html>
<head><title>400 Bad Request</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
<hr><center>cloudflare</center>
</body>
</html>

  at DiscordChatExporter.Core.Discord.DiscordClient.GetJsonResponseAsync(String url, CancellationToken cancellationToken) in {/path/to}/discord-chat-exporter/src/DiscordChatExporter-2.46/DiscordChatExporter.Core/Discord/DiscordClient.cs:160
  at DiscordChatExporter.Core.Discord.DiscordClient.GetGuildChannelsAsync(Snowflake guildId, CancellationToken cancellationToken)+MoveNext() in {/path/to}/discord-chat-exporter/src/DiscordChatExporter-2.46/DiscordChatExporter.Core/Discord/DiscordClient.cs:257
  at DiscordChatExporter.Core.Discord.DiscordClient.GetGuildChannelsAsync(Snowflake guildId, CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
  at DiscordChatExporter.Core.Exporting.ExportContext.PopulateChannelsAndRolesAsync(CancellationToken cancellationToken) in {/path/to}/discord-chat-exporter/src/DiscordChatExporter-2.46/DiscordChatExporter.Core/Exporting/ExportContext.cs:42
  at DiscordChatExporter.Core.Exporting.ExportContext.PopulateChannelsAndRolesAsync(CancellationToken cancellationToken) in {/path/to}/discord-chat-exporter/src/DiscordChatExporter-2.46/DiscordChatExporter.Core/Exporting/ExportContext.cs:42
  at DiscordChatExporter.Core.Exporting.ChannelExporter.ExportChannelAsync(ExportRequest request, IProgress`1 progress, CancellationToken cancellationToken) in {/path/to}/discord-chat-exporter/src/DiscordChatExporter-2.46/DiscordChatExporter.Core/Exporting/ChannelExporter.cs:32
  at DiscordChatExporter.Cli.Commands.Base.ExportCommandBase.<>c__DisplayClass67_3.<<ExportAsync>b__4>d.MoveNext()
  at DiscordChatExporter.Cli.Utils.Extensions.ConsoleExtensions.StartTaskAsync(ProgressContext context, String description, Func`2 performOperationAsync)
  at DiscordChatExporter.Cli.Commands.Base.ExportCommandBase.<>c__DisplayClass67_2.<<ExportAsync>b__3>d.MoveNext()
  at System.Threading.Tasks.Parallel.<>c__53`1.<<ForEachAsync>b__53_0>d.MoveNext()
  at DiscordChatExporter.Cli.Commands.Base.ExportCommandBase.<>c__DisplayClass67_0.<<ExportAsync>b__0>d.MoveNext()
  at Spectre.Console.Progress.<>c__DisplayClass31_0.<<StartAsync>b__0>d.MoveNext() in /_/src/Spectre.Console/Live/Progress/Progress.cs:103
  at Spectre.Console.Progress.<>c__DisplayClass32_0`1.<<StartAsync>b__0>d.MoveNext() in /_/src/Spectre.Console/Live/Progress/Progress.cs:138
  at Spectre.Console.Internal.DefaultExclusivityMode.RunAsync[T](Func`1 func) in /_/src/Spectre.Console/Internal/DefaultExclusivityMode.cs:40
  at Spectre.Console.Progress.StartAsync[T](Func`2 action) in /_/src/Spectre.Console/Live/Progress/Progress.cs:121
  at Spectre.Console.Progress.StartAsync(Func`2 action) in /_/src/Spectre.Console/Live/Progress/Progress.cs:101
  at DiscordChatExporter.Cli.Commands.Base.ExportCommandBase.ExportAsync(IConsole console, IReadOnlyList`1 channels)
  at DiscordChatExporter.Cli.Commands.ExportDirectMessagesCommand.ExecuteAsync(IConsole console)
  at CliFx.CliApplication.RunAsync(ApplicationSchema applicationSchema, CommandInput commandInput) in /_/CliFx/CliApplication.cs:144
  at CliFx.CliApplication.RunAsync(IReadOnlyList`1 commandLineArguments, IReadOnlyDictionary`2 environmentVariables) in /_/CliFx/CliApplication.cs:185

Checklist

  • I have looked through existing issues to make sure that this bug has not been reported before
  • I have provided a descriptive title for this issue
  • I have made sure that this bug is reproducible on the latest version of the application
  • I have provided all the information needed to reproduce this bug as efficiently as possible
  • I have sponsored this project
  • I have not read any of the above and just checked all the boxes to submit the issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions