fix(alerts): save recovery destinations on Postgres by keeping the column TEXT (#15574)

Co-authored-by: hengfeiyang <hengfei.yang@gmail.com>
This commit is contained in:
Dhruv
2026-10-23 04:02:34 +00:00
committed by GitHub
co-authored by hengfeiyang
parent 2125639a28
commit 455a8f82c4
2 changed files with 9 additions and 4 deletions
+8 -3
View File
@@ -80,8 +80,13 @@ impl TryFrom<alerts::Model> for MetaAlert {
let destinations: Vec<String> = serde_json::from_value(value.destinations)?;
let recovery_destinations: Vec<String> = value
.recovery_destinations
.map(serde_json::from_value)
.transpose()?
.map(|raw| serde_json::from_str(&raw))
.transpose()
.map_err(|e| {
errors::Error::Message(format!(
"alert {id} has an invalid recovery_destinations value: {e}"
))
})?
.unwrap_or_default();
let context_attributes: Option<HashMap<String, String>> = value
.context_attributes
@@ -961,7 +966,7 @@ fn update_mutable_fields(
let recovery_destinations = if alert.recovery_destinations.is_empty() {
None
} else {
Some(serde_json::to_value(alert.recovery_destinations)?)
Some(serde_json::to_string(&alert.recovery_destinations)?)
};
let keep_firing_for_seconds = alert.keep_firing_for;
+1 -1
View File
@@ -87,7 +87,7 @@ pub struct Model {
/// the alert predates the feature, which is the same as `false`.
pub notify_on_recovery: Option<bool>,
/// JSON array of destination names. NULL = the recovery follows the firing's own destinations.
pub recovery_destinations: Option<Json>,
pub recovery_destinations: Option<String>,
/// How long the condition must stay clear before the episode recovers.
/// NULL or 0 recovers on the first clear evaluation.
pub keep_firing_for_seconds: Option<i64>,