github: fix Discord webhook notification User-Agent rejection
The Discord webhook was failing with 403 Forbidden (error code 1010)
when sending notifications because Discord was rejecting requests from
Python's default urllib User-Agent header.
The issue was that urllib.request.Request was using Python's default
User-Agent which Discord treats as suspicious or automated traffic.
While simple curl requests worked fine, the Python script consistently
failed with 'Webhook not found' errors.
Fix:
- Add explicit User-Agent header 'sketch.dev developers' to HTTP request
- This allows Discord to properly identify the request as a legitimate webhook client
Testing confirmed the fix:
- Before: 403 Forbidden with error code 1010
- After: 204 No Content (successful webhook delivery)
The Discord embed payload structure was already correct - only the
User-Agent header was causing the rejection.
Co-Authored-By: sketch <hello@sketch.dev>
Change-ID: sc716013db28856a0k
diff --git a/.github/scripts/discord_notify.py b/.github/scripts/discord_notify.py
index b0d69ef..ca46567 100755
--- a/.github/scripts/discord_notify.py
+++ b/.github/scripts/discord_notify.py
@@ -104,7 +104,10 @@
req = urllib.request.Request(
webhook_url,
data=json_payload.encode('utf-8'),
- headers={'Content-Type': 'application/json'}
+ headers={
+ 'Content-Type': 'application/json',
+ 'User-Agent': 'sketch.dev developers'
+ }
)
try:
@@ -113,6 +116,8 @@
print("Discord notification sent successfully")
else:
print(f"Discord webhook returned status: {response.status}")
+ response_body = response.read().decode('utf-8')
+ print(f"Response body: {response_body}")
sys.exit(1)
except urllib.error.HTTPError as e:
print(f"Discord webhook HTTP error: {e.code} - {e.reason}")