Skip to content

fix webhook sink#2078

Merged
arikalon1 merged 3 commits into
masterfrom
webhook-sink-json-formatting
May 14, 2026
Merged

fix webhook sink#2078
arikalon1 merged 3 commits into
masterfrom
webhook-sink-json-formatting

Conversation

@arikalon1
Copy link
Copy Markdown
Contributor

add dynamic room for webex sink
make popeye container name fixed

arikalon1 added 2 commits May 12, 2026 20:20
add dynamic room for webex sink
make popeye container name fixed
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 12, 2026

Docker image ready for 6d1d06a (built in 33s)

⚠️ Warning: does not support ARM (ARM images are built on release only - not on every PR)

Use this tag to pull the image for testing.

📋 Copy commands

⚠️ Temporary images are deleted after 30 days. Copy to a permanent registry before using them:

gcloud auth configure-docker us-central1-docker.pkg.dev
docker pull us-central1-docker.pkg.dev/robusta-development/temporary-builds/robusta-runner:6d1d06a
docker tag us-central1-docker.pkg.dev/robusta-development/temporary-builds/robusta-runner:6d1d06a me-west1-docker.pkg.dev/robusta-development/development/robusta-runner-dev:6d1d06a
docker push me-west1-docker.pkg.dev/robusta-development/development/robusta-runner-dev:6d1d06a

Patch Helm values in one line:

helm upgrade --install robusta robusta/robusta \
  --reuse-values \
  --set runner.image=me-west1-docker.pkg.dev/robusta-development/development/robusta-runner-dev:6d1d06a

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

Review Change Stack

Walkthrough

This PR implements Webex dynamic room routing to direct alerts to different Webex rooms based on namespace and subject labels, refactors webhook JSON payload construction with explicit field ordering for truncation behavior, documents both features, and corrects the popeye scanner container naming.

Changes

Webex Dynamic Room Routing

Layer / File(s) Summary
Webex Configuration Parameters and Validation
src/robusta/core/sinks/webex/webex_sink_params.py
WebexSinkParams adds room_id_override, namespace_room_id_override, and send_to_default_if_missing fields with a Pydantic validator that normalizes override values via ChannelTransformer.
Room ID Resolution and Namespace Metadata
src/robusta/core/sinks/webex/webex_sink.py, src/robusta/integrations/kubernetes/api_client_utils.py
WebexSink._resolve_room_id evaluates namespace overrides (namespace labels/annotations), then general room overrides (finding labels/annotations), with template expansion and _UNRESOLVED sentinel for missing values; _get_namespace_metadata fetches namespace metadata safely; new get_namespace_annotations helper mirrors existing get_namespace_labels for annotation access.
Webex Sender Room Routing Integration
src/robusta/integrations/webex/sender.py
send_finding_to_webex accepts optional room_id parameter and derives target_room; message and file dispatch now use target_room instead of always using self.room_id.
Webex Dynamic Room Routing Documentation
docs/configuration/sinks/webex.rst
Documents override field behavior, ordered evaluation rules, send_to_default_if_missing fallback semantics, supported template syntax for labels/annotations, and provides two YAML examples demonstrating namespace-based routing with defaults and subject-based routing with drop behavior.

Webhook JSON Payload Format

Layer / File(s) Summary
Webhook JSON Payload Implementation
src/robusta/core/sinks/webhook/webhook_sink.py
__write_json replaces generic finding object serialization with explicit field-by-field dictionary construction, preserving platform_enabled-gated investigate/silence fields, and adding enrichments last so it is prioritized for dropping first when size_limit truncation occurs.
Webhook Configuration and JSON Payload Documentation
docs/configuration/sinks/webhook.rst
Adds "Configuration parameters" table documenting url, format, size_limit, authorization, and slack_webhook fields; adds "JSON payload" section describing POST body structure when format: json, including example payload, notes on platform-dependent investigate/silence fields, and truncation rules dropping enrichments first.

Popeye Container Name Fix

Layer / File(s) Summary
Fixed Popeye Scanner Container Name
playbooks/robusta_playbooks/popeye.py
PodSpec container name changed from image-derived value via to_kubernetes_name(IMAGE) to constant string "popeye-scanner".

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • pavangudiwada
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title 'fix webhook sink' is misleading as the PR primarily adds dynamic room routing for Webex and fixes the popeye container name, with webhook documentation updates being secondary. Update the title to reflect the main changes, such as 'Add dynamic room routing for Webex sink and fix popeye container name' or 'Add Webex dynamic room routing and webhook documentation'.
Docstring Coverage ⚠️ Warning Docstring coverage is 6.25% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description mentions adding dynamic room support for Webex and fixing the popeye container name, which aligns with the actual changes in the PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch webhook-sink-json-formatting

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

@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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/robusta/core/sinks/webhook/webhook_sink.py (1)

126-133: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Avoid stopping at the first oversized field.

Using break on overflow drops every subsequent key, so one large earlier field can prevent later fields from being included at all. That undermines the “enrichments last” truncation strategy.

Proposed fix
         for key, value in finding_dict.items():
             pair_length = len(json.dumps({key: value}).encode('utf-8'))

             if message_length + pair_length <= self.size_limit:
                 message[key] = value
                 message_length += pair_length
             else:
-                break
+                continue
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/robusta/core/sinks/webhook/webhook_sink.py` around lines 126 - 133, The
loop in webhook sink currently uses break when a field makes the message exceed
size_limit, which drops all subsequent fields and defeats the "enrichments last"
truncation strategy; change the logic in the loop over finding_dict so that when
pair_length would overflow you skip that field (use continue) instead of
breaking, and explicitly handle the case where a single field's pair_length is
larger than size_limit by skipping it as well (check pair_length >
self.size_limit), thereby allowing later fields to still be considered; update
the loop around finding_dict, message, message_length, and self.size_limit to
implement this behavior in the method where these variables are defined (e.g.,
the webhook sink method handling finding_dict).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/robusta/core/sinks/webhook/webhook_sink.py`:
- Line 95: The code adds finding.creation_date raw into the payload and then
computes JSON size via pair_length (which does json.dumps({key: value})), so if
creation_date is a datetime it will raise; convert/serialize creation_date the
same way other temporal fields are normalized (e.g., call the existing
time-normalization helper used in this module or use .isoformat() / str() to
produce a JSON-safe string) before inserting it into the dict and before calling
pair_length; apply the same change to both occurrences where "creation_date" is
added (the one referencing finding.creation_date and the other occurrence noted
in the review) and ensure you handle None values consistently.

---

Outside diff comments:
In `@src/robusta/core/sinks/webhook/webhook_sink.py`:
- Around line 126-133: The loop in webhook sink currently uses break when a
field makes the message exceed size_limit, which drops all subsequent fields and
defeats the "enrichments last" truncation strategy; change the logic in the loop
over finding_dict so that when pair_length would overflow you skip that field
(use continue) instead of breaking, and explicitly handle the case where a
single field's pair_length is larger than size_limit by skipping it as well
(check pair_length > self.size_limit), thereby allowing later fields to still be
considered; update the loop around finding_dict, message, message_length, and
self.size_limit to implement this behavior in the method where these variables
are defined (e.g., the webhook sink method handling finding_dict).
🪄 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: 8bc9cee2-800f-4a17-b497-baa7b124348e

📥 Commits

Reviewing files that changed from the base of the PR and between 11c8816 and b974846.

📒 Files selected for processing (8)
  • docs/configuration/sinks/webex.rst
  • docs/configuration/sinks/webhook.rst
  • playbooks/robusta_playbooks/popeye.py
  • src/robusta/core/sinks/webex/webex_sink.py
  • src/robusta/core/sinks/webex/webex_sink_params.py
  • src/robusta/core/sinks/webhook/webhook_sink.py
  • src/robusta/integrations/kubernetes/api_client_utils.py
  • src/robusta/integrations/webex/sender.py

Comment thread src/robusta/core/sinks/webhook/webhook_sink.py
@arikalon1 arikalon1 merged commit 369dbdb into master May 14, 2026
7 checks passed
@arikalon1 arikalon1 deleted the webhook-sink-json-formatting branch May 14, 2026 08:26
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