Skip to content

Conversation

@jasonwbarnett
Copy link
Contributor

Summary

Fixes two bugs in the Slack webhook example code that prevented messages from being sent to Slack:

  1. ReferenceError: body is not defined - Changed text: body to text: body_markdown (line 118)

    • The variable body was never defined in the webhook handler
    • Should use body_markdown which is extracted from the request body on line 92
  2. Invalid header block type - Changed header block text type from mrkdwn to plain_text (line 122)

    • Slack's header block type only supports plain_text, not mrkdwn
    • This was causing "must be a valid enum value" errors from the Slack API

Related Issue

Fixes #21294

@cdr-bot cdr-bot bot added the community Pull Requests and issues created by the community. label Dec 16, 2025
@github-actions
Copy link

github-actions bot commented Dec 16, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@jasonwbarnett jasonwbarnett force-pushed the jwb/fix-slack-webhook-errors branch 4 times, most recently from 578f3e9 to bd1f0d3 Compare December 16, 2025 17:56
@jasonwbarnett
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

cdrci2 added a commit to coder/cla that referenced this pull request Dec 16, 2025
- Fix ReferenceError by changing 'text: body' to 'text: body_markdown' on line 118
  (the variable 'body' was never defined; should use 'body_markdown' from req.body)
- Fix invalid_blocks API error by changing header block text type from 'mrkdwn' to 'plain_text' on line 122
  (Slack's header block type only supports plain_text, not mrkdwn)
- Rename 'title_markdown' to 'title' since the header block uses plain_text type, not markdown
  (variable names should reflect their actual content)

These errors were preventing webhook messages from being sent to Slack.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes two bugs in the Slack webhook integration example code that would prevent it from working correctly. The first fix resolves a ReferenceError by using the correct variable name (body_markdown instead of undefined body), and the second fix corrects the Slack API usage by changing the header block text type to plain_text (the only supported type for headers) instead of mrkdwn.

  • Fixed undefined variable reference in Slack message text field
  • Corrected Slack header block to use plain_text type as required by Slack's Block Kit API
  • Updated variable naming from title_markdown to title for consistency with plain text usage

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@mtojek mtojek left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution!

@mtojek mtojek merged commit f9087d6 into coder:main Dec 17, 2025
31 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Dec 17, 2025
@jasonwbarnett jasonwbarnett deleted the jwb/fix-slack-webhook-errors branch December 17, 2025 19:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

community Pull Requests and issues created by the community.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix ReferenceError and invalid_blocks errors in Slack webhook handler

2 participants