Skip to content

Add custom User-Agent header support for Mattermost integration#2045

Open
ckaytev wants to merge 1 commit intorobusta-dev:masterfrom
ckaytev:mattermost/user_agent_support
Open

Add custom User-Agent header support for Mattermost integration#2045
ckaytev wants to merge 1 commit intorobusta-dev:masterfrom
ckaytev:mattermost/user_agent_support

Conversation

@ckaytev
Copy link
Copy Markdown

@ckaytev ckaytev commented Apr 6, 2026

Summary

This PR adds the ability to override the default User-Agent header for Mattermost API requests.

Problem

Many enterprise environments deploy WAF solutions that automatically block or flag requests containing default HTTP client user agents (e.g., python-requests, python/3.12). This causes Robusta's Mattermost integration to fail in such environments, preventing alert notifications from being delivered.

By allowing users to customize the User-Agent header, Robusta can now work seamlessly in environments with strict WAF policies.

Configuration Example

sinksConfig:
- mattermost_sink:
    name: mattermost_sink
    url: https://mattermost.example.com
    token: <YOUR_BOT_TOKEN>
    token_id: <YOUR_BOT_TOKEN_ID>
    channel: alerts
    user_agent: "Robusta/1.0"  # Optional: custom User-Agent to bypass WAF

Backward Compatibility

This change is fully backward compatible. The user_agent parameter is optional and defaults to None. When not specified, the behavior remains unchanged (no custom User-Agent header is set, and the underlying HTTP client uses its default).

Testing

  • Verified that existing Mattermost integrations work without specifying user_agent
  • Tested custom User-Agent header is properly sent when configured

Signed-off-by: ckaytev <anton-ckayt@mail.ru>
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 6, 2026

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 6, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f7b9d1b5-1bec-4838-a794-0cf209f37853

📥 Commits

Reviewing files that changed from the base of the PR and between 7c8d299 and 9f8c60d.

📒 Files selected for processing (4)
  • docs/configuration/sinks/mattermost.rst
  • src/robusta/core/sinks/mattermost/mattermost_sink.py
  • src/robusta/core/sinks/mattermost/mattermost_sink_params.py
  • src/robusta/integrations/mattermost/client.py

Walkthrough

This pull request adds optional user_agent parameter support to the Mattermost sink. The parameter flows through the configuration schema, sink initialization, and Mattermost client, where it is conditionally included as a User-Agent header in API requests.

Changes

Cohort / File(s) Summary
Documentation
docs/configuration/sinks/mattermost.rst
Added user_agent field to the Mattermost sink configuration example in generated_values.yaml.
Configuration Schema
src/robusta/core/sinks/mattermost/mattermost_sink_params.py
Added optional user_agent: Optional[str] field to MattermostSinkParams.
Implementation
src/robusta/core/sinks/mattermost/mattermost_sink.py, src/robusta/integrations/mattermost/client.py
Updated MattermostSink to pass user_agent from config to MattermostClient constructor; enhanced MattermostClient to accept user_agent parameter and conditionally add User-Agent header to outgoing API requests.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: adding custom User-Agent header support for Mattermost integration.
Description check ✅ Passed The description clearly explains the problem, solution, configuration example, backward compatibility, and testing performed—all directly related to the changeset.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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