fix webhook sink#2078
Conversation
add dynamic room for webex sink make popeye container name fixed
|
✅ Docker image ready for
Use this tag to pull the image for testing. 📋 Copy commandsgcloud 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:6d1d06aPatch 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 |
WalkthroughThis 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. ChangesWebex Dynamic Room Routing
Webhook JSON Payload Format
Popeye Container Name Fix
🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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. Comment |
There was a problem hiding this comment.
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 winAvoid stopping at the first oversized field.
Using
breakon 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
📒 Files selected for processing (8)
docs/configuration/sinks/webex.rstdocs/configuration/sinks/webhook.rstplaybooks/robusta_playbooks/popeye.pysrc/robusta/core/sinks/webex/webex_sink.pysrc/robusta/core/sinks/webex/webex_sink_params.pysrc/robusta/core/sinks/webhook/webhook_sink.pysrc/robusta/integrations/kubernetes/api_client_utils.pysrc/robusta/integrations/webex/sender.py
add dynamic room for webex sink
make popeye container name fixed