From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 664E06939D for ; Tue, 23 Feb 2021 15:54:35 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5668B1FEA3 for ; Tue, 23 Feb 2021 15:54:05 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 3AACF1FE98 for ; Tue, 23 Feb 2021 15:54:04 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 00C38462E0 for ; Tue, 23 Feb 2021 15:54:04 +0100 (CET) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Tue, 23 Feb 2021 15:54:03 +0100 Message-Id: <20210223145403.2126-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.207 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment 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 Subject: [pbs-devel] [PATCH proxmox-backup] api2/config/tape_backup_job: fix duplicate id parameter X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Feb 2021 14:54:35 -0000 since the PUT api call is using the 'Updater', the 'id' parameter is already encoded in there, tripping up the api verify tests with 'Duplicate keys found in AllOf schema: id' "fixing" it by removing the explicit id from the api call and taking it from the Updater (and failing if it does not exists there; even though that should never happen) Signed-off-by: Dominik Csapak --- i am *really* not sure if this is the correct way @Wolfgang, is there another wayt to selectively use the struct members for the Updater? src/api2/config/tape_backup_job.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/api2/config/tape_backup_job.rs b/src/api2/config/tape_backup_job.rs index a9edc00f..bc05704c 100644 --- a/src/api2/config/tape_backup_job.rs +++ b/src/api2/config/tape_backup_job.rs @@ -1,4 +1,4 @@ -use anyhow::{bail, Error}; +use anyhow::{bail, format_err, Error}; use serde_json::Value; use ::serde::{Deserialize, Serialize}; @@ -123,9 +123,6 @@ pub enum DeletableProperty { protected: true, input: { properties: { - id: { - schema: JOB_ID_SCHEMA, - }, update: { flatten: true, type: TapeBackupJobConfigUpdater, @@ -147,13 +144,14 @@ pub enum DeletableProperty { )] /// Update the tape backup job pub fn update_tape_backup_job( - id: String, - update: TapeBackupJobConfigUpdater, + mut update: TapeBackupJobConfigUpdater, delete: Option>, digest: Option, ) -> Result<(), Error> { let _lock = open_file_locked(TAPE_JOB_CFG_LOCKFILE, std::time::Duration::new(10, 0), true)?; + let id = update.id.take().ok_or_else(|| format_err!("no id given"))?; + let (mut config, expected_digest) = config::tape_job::config()?; let mut job: TapeBackupJobConfig = config.lookup("backup", &id)?; -- 2.20.1