From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 2B1101FF0C0 for ; Wed, 21 Oct 2026 16:39:38 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 3CF0F21464; Wed, 21 Oct 2026 16:39:37 +0200 (CEST) Content-Type: text/plain; charset=UTF-8 Date: Wed, 21 Oct 2026 16:39:33 +0200 Message-Id: Subject: Re: [PATCH proxmox v4 12/39] notify: matcher: add expression support From: =?utf-8?q?Michael_K=C3=B6ppl?= To: "Lukas Wagner" , , Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 X-Mailer: aerc 0.22.0 References: <20261012131413.314088-1-l.wagner@proxmox.com> <20261012131413.314088-13-l.wagner@proxmox.com> In-Reply-To: <20261012131413.314088-13-l.wagner@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1792593573132 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.088 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) POISEN_SPAM_PILL 0.1 Meta: its spam POISEN_SPAM_PILL_1 0.1 random spam to be learned in bayes POISEN_SPAM_PILL_3 0.1 random spam to be learned in bayes RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: O7USLC6ORV6GOD3P25XE6WQYUWEXLOJM X-Message-ID-Hash: O7USLC6ORV6GOD3P25XE6WQYUWEXLOJM X-MailFrom: m.koeppl@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Mon Oct 12, 2026 at 3:13 PM CEST, Lukas Wagner wrote: [snip] > diff --git a/proxmox-notify/src/matcher/field.rs b/proxmox-notify/src/mat= cher/field.rs > index ad04b388..fd25939c 100644 > --- a/proxmox-notify/src/matcher/field.rs > +++ b/proxmox-notify/src/matcher/field.rs > @@ -6,6 +6,7 @@ use regex::Regex; > use proxmox_schema::{ > ApiStringFormat, Schema, StringSchema, api_types::SAFE_ID_REGEX_STR,= const_regex, > }; > +use serde::{Deserialize, Serialize}; > > use crate::{Error, Notification}; > > @@ -30,42 +31,38 @@ pub const MATCH_FIELD_ENTRY_SCHEMA: Schema =3D String= Schema::new("Match metadata f > .schema(); > > /// Check if the notification metadata fields match > -#[derive(Clone, Debug)] > +#[derive(Clone, Debug, Serialize, Deserialize)] > +#[serde(rename_all =3D "kebab-case", untagged)] Via the API or CLI, I can supply an expression with keys that are AFAIU mutually exclusive: ``` pvesh create /cluster/notifications/matchers \ --name notsupposedtowork \ --target mail-to-root \ --expression \ '{"match":{"type":"field","field":"type","values":["vzdump"],"regex":"^rep= lication$"}}' ``` This will be accepted, but the config will only contain this: ``` matcher: notsupposedtowork expression {"match":{"type":"field","field":"type","values":["vzdump"]}} target mail-to-root ``` So it silently drops the second key. I think this should probably be rejected, no? I think adding `deny_unknown_fields` should resolve this. Because then, if the field matcher has the form `{"field": "...", "values": [...]}`, "regex" will be unknown. Analogously if the field matcher is the regex form, then "values" will be unknown. Wouldn't see this as a blocker, though. Could also be resolved as a follow-up IMO. > pub enum FieldMatcher { > Exact { > field: String, > - matched_values: Vec, > + values: Vec, > }, > Regex { > field: String, > - matched_regex: Regex, > + #[serde(with =3D "serde_regex")] > + regex: Regex, > }, > } [snip]