Skip to content

fix(bug): added missing json=payload for the mattermost destination - #7779

Open
MkhalFadel wants to merge 3 commits into
getredash:masterfrom
MkhalFadel:fix-mattermost-destination
Open

fix(bug): added missing json=payload for the mattermost destination #7779
MkhalFadel wants to merge 3 commits into
getredash:masterfrom
MkhalFadel:fix-mattermost-destination

Conversation

@MkhalFadel

@MkhalFadel MkhalFadel commented Aug 3, 2026

Copy link
Copy Markdown

What type of PR is this?

  • Bug Fix
  • [ ]

Description

How is this tested?

  • Unit tests (pytest, jest)
  • E2E Tests (Cypress)
  • Manually
  • N/A

Related Tickets & Documents

Mobile & Desktop Screenshots/Recordings (if there are UI changes)


The PR fixes missing .encode("utf-8") in the mattermost.py file for the Mattermost class in line 47

Review in cubic

@greptile-apps

greptile-apps Bot commented Aug 3, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes the Mattermost webhook destination by replacing data=json_dumps(payload) with json=payload in the requests.post call, which ensures the payload is properly serialized and the Content-Type: application/json header is automatically set — both were missing before, likely causing Mattermost to reject webhook payloads.

  • Core fix: Switching to json=payload makes requests handle serialization and sets the correct content type header, resolving the broken webhook delivery.
  • Cleanup needed: The json_dumps import from redash.utils is now unused and should be removed.

Confidence Score: 5/5

  • Safe to merge — the one-line change correctly fixes webhook delivery by using the json= kwarg, and the only remaining item is an unused import cleanup.
  • The change is small and targeted, switching from a raw data= call (missing Content-Type: application/json) to json=payload, which is the idiomatic requests approach for JSON payloads. The logic is straightforwardly correct and the rest of the notify method is untouched.
  • No files require special attention.

Important Files Changed

Filename Overview
redash/destinations/mattermost.py Replaces data=json_dumps(payload) with json=payload so requests automatically serializes the payload and sets the Content-Type: application/json header, fixing webhook delivery to Mattermost. The now-unused json_dumps import should be cleaned up.

Sequence Diagram

sequenceDiagram
    participant Redash
    participant Mattermost

    Note over Redash,Mattermost: Before fix
    Redash->>Mattermost: "POST /webhook (data=json_string, no Content-Type header)"
    Mattermost-->>Redash: 400 / ignored (missing Content-Type)

    Note over Redash,Mattermost: After fix
    Redash->>Mattermost: "POST /webhook (json=payload, Content-Type: application/json)"
    Mattermost-->>Redash: 200 OK
Loading

Reviews (3): Last reviewed commit: "Merge branch 'master' into fix-mattermos..." | Re-trigger Greptile

Comment thread redash/destinations/mattermost.py Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 1 file

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread redash/destinations/mattermost.py Outdated
@MkhalFadel MkhalFadel changed the title fix(bug): added missing .encode(utf-8) for the mattermost destination fix(bug): added missing json=payload for the mattermost destination Aug 4, 2026
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.

1 participant