From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id EA9AC1FF14C for ; Fri, 26 Jun 2026 11:32:56 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 61155B105; Fri, 26 Jun 2026 11:32:56 +0200 (CEST) From: Christoph Heiss To: pdm-devel@lists.proxmox.com Subject: [PATCH proxmox] rest-server: throw meaningful error if template file does not exist Date: Fri, 26 Jun 2026 11:32:22 +0200 Message-ID: <20260626093248.271176-1-c.heiss@proxmox.com> X-Mailer: git-send-email 2.54.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1782466366493 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.077 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment 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: T7KYVFAHFZ7RSTZKJMFYGDIVL3WP76N5 X-Message-ID-Hash: T7KYVFAHFZ7RSTZKJMFYGDIVL3WP76N5 X-MailFrom: c.heiss@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 Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Otherwise, users just fail on startup while constructing an `ApiConfig` instance, with this pretty unhelpful error message: Error: No such file or directory (os error 2) Give some context to make it easier to trace down these errors in the future. Signed-off-by: Christoph Heiss --- Noticed this while building the latest master of proxmox-datacenter-manager, which requires a new template as of 60a1c406 ("server: add and serve template for novnc") .. but the corresponding package hasn't been bumped yet. proxmox-rest-server/src/api_config.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/proxmox-rest-server/src/api_config.rs b/proxmox-rest-server/src/api_config.rs index 6c5c0aea..2f590018 100644 --- a/proxmox-rest-server/src/api_config.rs +++ b/proxmox-rest-server/src/api_config.rs @@ -421,6 +421,10 @@ mod templates { } let path: PathBuf = path.into(); + if !path.exists() { + bail!("template file not found: {}", path.display()); + } + let metadata = metadata(&path)?; let mtime = metadata.modified()?; -- 2.54.0