Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/robusta/core/model/sinks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from typing import Optional
from pydantic import BaseModel, Field
from robusta.core.model.base_params import ActionParams


class DelayedNotificationConfig(BaseModel):
"""
Configuration for delayed notifications
:var delay_seconds: Number of seconds to delay the notification
:var condition: Optional condition that must be met for the delay to apply
"""
delay_seconds: int = Field(ge=0, description="Number of seconds to delay the notification")
condition: Optional[str] = Field(None, description="Optional condition for applying the delay")
Comment on lines +10 to +13
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

The condition field is declared but not evaluated.

The condition field is defined here but get_delay_seconds() doesn't check it—delays will always apply regardless of any condition set. If this is intentional scaffolding for future implementation, consider adding a comment or TODO. Otherwise, users may set a condition expecting it to be honored.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/robusta/core/model/sinks.py` around lines 10 - 13, The get_delay_seconds
method currently ignores the Optional[str] field condition, so any configured
condition is not evaluated and delays always apply; update get_delay_seconds to
evaluate the condition (or explicitly short-circuit) before returning
delay_seconds—use the existing condition field on the same model and return 0
(or None/skip) when the condition does not evaluate to true for the given
alert/context, or if you cannot implement evaluation now add a clear TODO
comment in get_delay_seconds noting that condition must be evaluated and
referencing the condition and delay_seconds fields so future work implements
expression parsing/execution.



class SinkBaseParams(ActionParams):
"""
Base class for all sink configurations
"""
name: str
notification_delay_seconds: Optional[int] = Field(None, ge=0, description="Delay notification by specified seconds")
delayed_notification_config: Optional[DelayedNotificationConfig] = Field(
None, description="Advanced delayed notification configuration"
)

def get_delay_seconds(self) -> int:
"""Get the effective delay in seconds"""
if self.delayed_notification_config:
return self.delayed_notification_config.delay_seconds
return self.notification_delay_seconds or 0