From: Jakob-Tobias Winter <tobias@stuttgart.de>
To: tobias@linuxdingsda.de, pbs-devel@lists.proxmox.com
Cc: Jakob-Tobias Winter <tobias@stuttgart.de>
Subject: [PATCH proxmox-backup] bin: debug: api: fix panic on parameters given more than once
Date: Mon, 9 Nov 2026 22:59:38 +0100 [thread overview]
Message-ID: <20261109215938.903397-1-tobias@stuttgart.de> (raw)
Array parameters, for example 'group-filter', are set by giving the
parameter once per value. The command line parser collects the values of
a repeated parameter in an array, while the 'api' subcommands expected a
single string for each parameter and panicked with "entered unreachable
code". So array parameters could only be passed with one value.
Hand each value over to the parameter verification separately. Array
parameters now accept more than one value, and other parameters that are
given more than once get rejected as duplicate instead of causing a
panic.
Signed-off-by: Jakob-Tobias Winter <tobias@stuttgart.de>
---
Reproducer:
proxmox-backup-debug api create /config/tape-backup-job --id two \
--store store1 --pool pool1 --drive drive1 \
--group-filter type:vm --group-filter group:ct/200
Tested with debug builds of current master and of 4.2.8, calling the API
in-process (PROXMOX_DEBUG_API_CODE=1): the call panics without the patch
and creates the job with both filters with it. Calls without a repeated
parameter print the same as before. The HTTP path was not tested.
src/bin/proxmox_backup_debug/api.rs | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/src/bin/proxmox_backup_debug/api.rs b/src/bin/proxmox_backup_debug/api.rs
index 61cd1b7db..39f8c2100 100644
--- a/src/bin/proxmox_backup_debug/api.rs
+++ b/src/bin/proxmox_backup_debug/api.rs
@@ -153,15 +153,21 @@ fn merge_parameters(
.collect();
if let Some(Value::Object(map)) = param {
- param_list.extend(map.into_iter().map(|(k, v)| {
- (
- k,
- match v {
- Value::String(s) => s,
- _ => unreachable!(), // we're in the CLI
- },
- )
- }));
+ for (k, v) in map {
+ match v {
+ Value::String(s) => param_list.push((k, s)),
+ // a parameter given more than once is collected into an array
+ Value::Array(list) => {
+ for item in list {
+ match item {
+ Value::String(s) => param_list.push((k.clone(), s)),
+ _ => unreachable!(), // we're in the CLI
+ }
+ }
+ }
+ _ => unreachable!(), // we're in the CLI
+ }
+ }
}
let params = schema.parse_parameter_strings(¶m_list, true)?;
--
2.53.0
reply other threads:[~2026-11-09 22:07 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261109215938.903397-1-tobias@stuttgart.de \
--to=tobias@stuttgart.de \
--cc=pbs-devel@lists.proxmox.com \
--cc=tobias@linuxdingsda.de \
/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