From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id DB2EC1FF0AB for ; Wed, 07 Oct 2026 11:32:41 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id DE418215DA; Wed, 07 Oct 2026 11:32:35 +0200 (CEST) Content-Type: text/plain; charset=UTF-8 Date: Wed, 07 Oct 2026 11:32:24 +0200 Message-Id: From: =?utf-8?q?Michael_K=C3=B6ppl?= To: "Lukas Wagner" , , Subject: Re: [PATCH proxmox v2 13/34] notify: api: support new expression parameter Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 X-Mailer: aerc 0.22.0 References: <20261001083706.144246-1-l.wagner@proxmox.com> <20261001083706.144246-14-l.wagner@proxmox.com> In-Reply-To: <20261001083706.144246-14-l.wagner@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1791365544719 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.306 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) 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: ZSFIMV3YMJSHIMVF5EMMXUMRF7ONB4OJ X-Message-ID-Hash: ZSFIMV3YMJSHIMVF5EMMXUMRF7ONB4OJ 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 VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Thu Oct 1, 2026 at 10:36 AM CEST, Lukas Wagner wrote: [snip] > + fn ensure_no_ignored_properties(&self) -> Result<(), Error> { > + if self.expression.is_some() { > + let conflicting_properties =3D self.properties_conflicting_w= ith_expression(); > + > + if !conflicting_properties.is_empty() { > + let joined =3D conflicting_properties.join(", "); > + return Err(Error::Generic(format!( > + "'expression' property is mutually exclusive with: {= joined}" > + ))); > + } > + } > + > + Ok(()) > + } > + > + fn ensure_valid_expression(&self) -> Result<(), Error> { > + if let Some(expression) =3D &self.expression { > + match serde_json::from_str::= >(expression) { > + Ok(expr) =3D> { When the expression passed in is pretty-printed JSON (e.g. if read from a JSON file as part of a script or something similar), this check here still work, but the original unescaped string is what gets stored, which fails with could not serialize configuration: writing "notifications.cfg" failed: detected unexpected control character in section 'json-pretty' key 'expression' Since parsing happens here already anyway, perhaps the parsed expression could be used in add_matcher() and update_matcher() instead of the original string? > + Self::verify_match_expression_constraints(&expr)?; > + } > + Err(err) =3D> { > + return Err(Error::Generic(format!( > + "'expression' is not valid: {err:#}" > + ))); > + } > + } > + } > + > + Ok(()) > + } > + [snip]