Skip to content

Improve Discord API error handling and webhook checks#469

Merged
siddharthvaddem merged 1 commit intosiddharthvaddem:mainfrom
imAaryash:feat/discord-actions
Apr 19, 2026
Merged

Improve Discord API error handling and webhook checks#469
siddharthvaddem merged 1 commit intosiddharthvaddem:mainfrom
imAaryash:feat/discord-actions

Conversation

@imAaryash
Copy link
Copy Markdown
Collaborator

@imAaryash imAaryash commented Apr 19, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Improved Discord webhook response handling to gracefully process different content types and prevent parsing failures.
    • Enhanced webhook secret validation with flexible enforcement based on workflow event type for improved reliability.

Refactor error handling for Discord API responses and improve webhook secret checks.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 19, 2026

📝 Walkthrough

Walkthrough

Updated Discord workflow webhook response handling to conditionally parse JSON responses and made webhook-secret validation conditional based on event type (pull_request_target and workflow_dispatch enforce validation, others warn only).

Changes

Cohort / File(s) Summary
Discord Webhook Handling
.github/workflows/discord.yaml
Improved response parsing to check content-type header before JSON parsing, preventing failures on non-JSON 2xx responses; made webhook-secret validation conditional based on event type—strict enforcement for pull_request_target and workflow_dispatch, warnings only for others.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • siddharthvaddem

Poem

🤖 Discord webhooks at 2am—
conditional logic takes the stage,
json parsed when it's meant,
secrets fail on strict days,
warnings whisper for the rest. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning No pull request description was provided, missing all required template sections including Description, Motivation, Type of Change, and Testing details. Add a complete description covering why these changes are needed, what problem they solve, the type of change, and how reviewers can test it.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed Title clearly and specifically summarizes the main changes: improved Discord API error handling and webhook validation checks.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/discord.yaml:
- Around line 213-218: The strict-events set includes "workflow_dispatch" but
that check never runs because getPullRequest() returns null for manual runs and
causes an early return; either remove "workflow_dispatch" from the strictEvents
Set to avoid misleading enforcement, or if you do want manual runs to require a
webhook, move the webhook-secret check (the strictEvents/ctx.eventName logic) to
run before getPullRequest() is called so workflow_dispatch hits that branch;
update the Set or reorder the code accordingly while keeping references to
strictEvents, context.eventName, and getPullRequest().
- Around line 113-118: The current response-parsing branch silently returns {}
for non-JSON responses which hides missing channel_id for thread creation;
update the parser so callers that perform creations (discordPost called with
createPayload) require a JSON response: add a flag/parameter (e.g.,
requireJsonForCreate) or detect createPayload presence in discordPost and, when
set, avoid the fallback path and throw or return an error if contentType does
not include "application/json" (instead of returning {}); keep the permissive
warning+{} behavior for non-create calls. Ensure you modify the code path that
checks contentType.includes("application/json") and the callers
(discordPost/createPayload) so create requests enforce JSON and propagate the
error to fail the workflow rather than returning an empty object.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 80b4e45c-fa1d-451f-9c82-36590d68fd5f

📥 Commits

Reviewing files that changed from the base of the PR and between 10463f8 and cfc6579.

📒 Files selected for processing (1)
  • .github/workflows/discord.yaml

Comment thread .github/workflows/discord.yaml
Comment thread .github/workflows/discord.yaml
@siddharthvaddem siddharthvaddem merged commit fd6a077 into siddharthvaddem:main Apr 19, 2026
12 of 13 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Apr 19, 2026
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants