Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misleading API response for Cloudflare blocked requests #6473

Open
hackermondev opened this issue Oct 3, 2023 · 4 comments
Open

Misleading API response for Cloudflare blocked requests #6473

hackermondev opened this issue Oct 3, 2023 · 4 comments
Labels
api API issue synced Synced to internal tracker

Comments

@hackermondev
Copy link
Contributor

Description

Discord recently changed their Cloudflare configuration to return a JSON error when the user is Cloudflare blocked instead of the HTML Cloudflare page.

Example response:

{
    "message": "internal network error",
    "code": 40333
}

This error is misleading, "internal network error" might make someone think Discord is having issues with their API.

Steps to Reproduce

Discord blocks Bot API requests with browser user agents, you can reproduce it with this command:

curl 'https://canary.discord.com/api/v9/channels/1051241605241262192/messages?limit=50' \
  -H 'authority: canary.discord.com' \
  -H 'authorization: Bot 1' \
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) discord/0.0.314 Chrome/108.0.5359.215 Electron/22.3.25 Safari/537.36' \
  --compressed

Expected Behavior

The API should return a more informative error like "Request blocked"

Current Behavior

{
    "message": "internal network error",
    "code": 40333
}

Screenshots/Videos

No response

Client and System Information

N/A

@devsnek devsnek added api API issue synced Synced to internal tracker and removed bug labels Oct 3, 2023
@totallytavi
Copy link

I can confirm this is still occurring. I recently encountered this when trying to send requests from Roblox through a proxy and blindly copied the User-Agent.

@kiecooboi
Copy link

me 2

@BokononLives
Copy link

Whether or not the error message gets updated, I would like to see this user-agent requirement added to public documentation (if it isn't already) if it is here to stay. I encountered this issue, and it was tricky to identify. I hadn't considered that my PowerShell script was automatically supplying a user agent header containing "Mozilla" even when I didn't specify one - so it was not obvious at first what "40333 - internal network error" was trying to tell me. Thank you for your consideration!

@OoLunar
Copy link

OoLunar commented Nov 16, 2024

More information on why a request is blocked is highly desirable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api API issue synced Synced to internal tracker
Projects
None yet
Development

No branches or pull requests

7 participants
@BokononLives @devsnek @kiecooboi @OoLunar @hackermondev @totallytavi and others