public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup] api2/config/tape_backup_job: fix duplicate id parameter
Date: Tue, 23 Feb 2021 15:54:03 +0100	[thread overview]
Message-ID: <20210223145403.2126-1-d.csapak@proxmox.com> (raw)

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 <d.csapak@proxmox.com>
---
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<Vec<String>>,
     digest: Option<String>,
 ) -> 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





             reply	other threads:[~2021-02-23 14:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-23 14:54 Dominik Csapak [this message]
2021-02-23 16:26 ` [pbs-devel] applied: " Dietmar Maurer
2021-02-23 17:00   ` Thomas Lamprecht
2021-02-23 19:27     ` Dietmar Maurer
2021-02-24  6:13       ` Dietmar Maurer
2021-02-24  7:28         ` Dietmar Maurer
2021-02-24  8:35           ` Wolfgang Bumiller
2021-02-24  8:42             ` Dietmar Maurer
2021-02-24  9:02               ` Wolfgang Bumiller
2021-02-24  9:47                 ` Dietmar Maurer
2021-02-25  8:53                   ` Dietmar Maurer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210223145403.2126-1-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal