]> git.proxmox.com Git - proxmox-backup.git/commitdiff
ExtJsFormatter: use ParameterError to correctly compute 'errors'
authorDietmar Maurer <dietmar@proxmox.com>
Tue, 28 Sep 2021 08:11:56 +0000 (10:11 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 28 Sep 2021 08:19:55 +0000 (10:19 +0200)
By default, 'errors' is now empty.

Depend on proxmox 0.13.5.

15 files changed:
Cargo.toml
pbs-api-types/Cargo.toml
pbs-client/Cargo.toml
pbs-config/Cargo.toml
pbs-datastore/Cargo.toml
pbs-fuse-loop/Cargo.toml
pbs-tape/Cargo.toml
pbs-tools/Cargo.toml
proxmox-backup-client/Cargo.toml
proxmox-file-restore/Cargo.toml
proxmox-rest-server/Cargo.toml
proxmox-rest-server/src/formatter.rs
proxmox-restore-daemon/Cargo.toml
proxmox-systemd/Cargo.toml
pxar-bin/Cargo.toml

index 88e8fbd1ff2882ebd9f756a450c7dbbec44e68f7..76bde80d748dac4351dbf802a55266aacbc6debb 100644 (file)
@@ -94,7 +94,7 @@ zstd = { version = "0.6", features = [ "bindgen" ] }
 pathpatterns = "0.1.2"
 pxar = { version = "0.10.1", features = [ "tokio-io" ] }
 
-proxmox = { version = "0.13.4", features = [ "sortable-macro", "api-macro", "cli", "router", "tfa" ] }
+proxmox = { version = "0.13.5", features = [ "sortable-macro", "api-macro", "cli", "router", "tfa" ] }
 proxmox-acme-rs = "0.2.1"
 proxmox-apt = "0.7.0"
 proxmox-http = { version = "0.4.0", features = [ "client", "http-helpers", "websocket" ] }
index 878d6417eaa965d772ce5caba89b831eab74f7c1..1ca768de6a4e525c8da26a022f6e4f7994cdb265 100644 (file)
@@ -14,7 +14,7 @@ openssl = "0.10"
 regex = "1.2"
 serde = { version = "1.0", features = ["derive"] }
 
-proxmox = { version = "0.13.4", default-features = false, features = [ "api-macro" ] }
+proxmox = { version = "0.13.5", default-features = false, features = [ "api-macro" ] }
 
 proxmox-systemd = { path = "../proxmox-systemd" }
 pbs-tools = { path = "../pbs-tools" }
index dc5d8928bbd95a8655622c5289013f3996cdffe9..83ef65a9a2529c546cafb7d904fb15984589406f 100644 (file)
@@ -28,7 +28,7 @@ tower-service = "0.3.0"
 xdg = "2.2"
 
 pathpatterns = "0.1.2"
-proxmox = { version = "0.13.4", default-features = false, features = [ "cli" ] }
+proxmox = { version = "0.13.5", default-features = false, features = [ "cli" ] }
 proxmox-fuse = "0.1.1"
 proxmox-http = { version = "0.4.0", features = [ "client", "http-helpers", "websocket" ] }
 pxar = { version = "0.10.1", features = [ "tokio-io" ] }
index 3249a8e9cb0d2dd7cd2369159037ef09c9019201..7936686a373a38da0d57378dd1c3bd1acf942944 100644 (file)
@@ -16,7 +16,7 @@ nix = "0.19.1"
 regex = "1.2"
 once_cell = "1.3.1"
 
-proxmox = { version = "0.13.4", default-features = false, features = [ "cli" ] }
+proxmox = { version = "0.13.5", default-features = false, features = [ "cli" ] }
 
 pbs-api-types = { path = "../pbs-api-types" }
 pbs-buildcfg = { path = "../pbs-buildcfg" }
index 077ead4739758effe25198c8265c1d222e67105b..45c0d2769debaba5f8c62f79ed93c9927585d798 100644 (file)
@@ -25,7 +25,7 @@ zstd = { version = "0.6", features = [ "bindgen" ] }
 pathpatterns = "0.1.2"
 pxar = "0.10.1"
 
-proxmox = { version = "0.13.4", default-features = false, features = [ "api-macro" ] }
+proxmox = { version = "0.13.5", default-features = false, features = [ "api-macro" ] }
 
 pbs-api-types = { path = "../pbs-api-types" }
 pbs-tools = { path = "../pbs-tools" }
index aa61d00688c7280de54b849d63d87734b9e6f887..337ab9bdb90bce08677bb033cc5bb20ab6b3b3d1 100644 (file)
@@ -14,7 +14,7 @@ nix = "0.19.1"
 regex = "1.2"
 tokio = { version = "1.6", features = [] }
 
-proxmox = "0.13.4"
+proxmox = "0.13.5"
 proxmox-fuse = "0.1.1"
 
 pbs-tools = { path = "../pbs-tools" }
index 3dbeb17cb970254c3ee8945e4aea26965c04d641..9224cee29a57cae03c525edc3bc10f6735c03089 100644 (file)
@@ -18,7 +18,7 @@ bitflags = "1.2.1"
 regex = "1.2"
 udev = ">= 0.3, <0.5"
 
-proxmox = { version = "0.13.4", default-features = false, features = [] }
+proxmox = { version = "0.13.5", default-features = false, features = [] }
 
 pbs-api-types = { path = "../pbs-api-types" }
 pbs-tools = { path = "../pbs-tools" }
index d37ef8651dd717225d5f4623dab72b60b363c1a8..7a33ab5e7417c28f9399a59bc8ddccfb38e3d2e5 100644 (file)
@@ -31,7 +31,7 @@ url = "2.1"
 walkdir = "2"
 zstd = { version = "0.6", features = [ "bindgen" ] }
 
-proxmox = { version = "0.13.4", default-features = false, features = [ "tokio" ] }
+proxmox = { version = "0.13.5", default-features = false, features = [ "tokio" ] }
 
 pbs-buildcfg = { path = "../pbs-buildcfg" }
 pbs-runtime = { path = "../pbs-runtime" }
index 42a4d09fd002c10f04613adc40e68137c6f2fed3..0b1d7f3bf7f3aad073711392c8d47a90ba4dcbd4 100644 (file)
@@ -22,7 +22,7 @@ zstd = { version = "0.6", features = [ "bindgen" ] }
 pathpatterns = "0.1.2"
 pxar = { version = "0.10.1", features = [ "tokio-io" ] }
 
-proxmox = { version = "0.13.4", features = [ "sortable-macro", "api-macro", "cli", "router" ] }
+proxmox = { version = "0.13.5", features = [ "sortable-macro", "api-macro", "cli", "router" ] }
 
 pbs-api-types = { path = "../pbs-api-types" }
 pbs-buildcfg = { path = "../pbs-buildcfg" }
index 899fc984acbd3f8c577b72336a73587637c87f85..382aa34fb7d011e6745a659ff598cc62ff46c7a1 100644 (file)
@@ -16,7 +16,7 @@ tokio = { version = "1.6", features = [ "io-std", "rt", "rt-multi-thread", "time
 
 pxar = { version = "0.10.1", features = [ "tokio-io" ] }
 
-proxmox = { version = "0.13.4", features = [ "api-macro", "cli" ] }
+proxmox = { version = "0.13.5", features = [ "api-macro", "cli" ] }
 
 pbs-api-types = { path = "../pbs-api-types" }
 pbs-buildcfg = { path = "../pbs-buildcfg" }
index afaf40e1beed5b718d85a12bb93c0037e361521f..b0e53d192194fde1e2539f7335eb907735860207 100644 (file)
@@ -25,7 +25,7 @@ tokio-openssl = "0.6.1"
 tower-service = "0.3.0"
 url = "2.1"
 
-proxmox = { version = "0.13.4", features = [ "router"] }
+proxmox = { version = "0.13.5", features = [ "router"] }
 
 # fixme: remove this dependency (pbs_tools::broadcast_future)
 pbs-tools = { path = "../pbs-tools" }
index 7f41b3828395f761990e5260e720e9ed3fd3625a..601a756137a4c9817bf883d2f5a843e5727dfca8 100644 (file)
@@ -6,7 +6,7 @@ use serde_json::{json, Value};
 use hyper::{Body, Response, StatusCode};
 use hyper::header;
 
-use proxmox::api::{HttpError, RpcEnvironment};
+use proxmox::api::{HttpError, schema::ParameterError, RpcEnvironment};
 
 /// Extension to set error message for server side logging
 pub(crate) struct ErrorMessageExtension(pub String);
@@ -61,6 +61,12 @@ struct JsonFormatter();
 
 /// Format data as ``application/json``
 ///
+/// The returned json object contains the following properties:
+///
+/// * ``data``: The result data (on success)
+///
+/// Any result attributes set on ``rpcenv`` are also added to the object.
+///
 /// Errors generates a BAD_REQUEST containing the error
 /// message as string.
 pub static JSON_FORMATTER: &'static dyn OutputFormatter = &JsonFormatter();
@@ -136,10 +142,18 @@ impl  OutputFormatter for ExtJsFormatter {
 
     fn format_error(&self, err: Error) -> Response<Body> {
 
-        let mut errors = vec![];
+        let message: String;
+        let errors;
 
-        let message = err.to_string();
-        errors.push(&message);
+        if let Some(param_err) = err.downcast_ref::<ParameterError>() {
+            errors = param_err.errors().iter()
+                .map(|(name, err)| format!("parameter '{}': {}", name, err))
+                .collect();
+            message = String::from("parameter verification errors");
+        } else {
+            errors = vec![];
+            message = err.to_string();
+        }
 
         let result = json!({
             "message": message,
index 871af5f9dd39c68c75a949fbbbff0fc8edd7d8a8..3fbf552e839aa992ea89076d6db41b3f029a1cc5 100644 (file)
@@ -26,7 +26,7 @@ tokio-util = { version = "0.6", features = [ "codec", "io" ] }
 pathpatterns = "0.1.2"
 pxar = { version = "0.10.1", features = [ "tokio-io" ] }
 
-proxmox = { version = "0.13.4", features = [ "router", "sortable-macro" ] }
+proxmox = { version = "0.13.5", features = [ "router", "sortable-macro" ] }
 
 pbs-api-types = { path = "../pbs-api-types" }
 pbs-runtime = { path = "../pbs-runtime" }
index 017a281c32c18125c6bda05262c10964393aca51..ea715bf43fe4033a031a288fa55af82a46e3f065 100644 (file)
@@ -11,6 +11,6 @@ bitflags = "1.2.1"
 lazy_static = "1.4"
 nom = "5.1"
 
-proxmox = { version = "0.13.4", default-features = false }
+proxmox = { version = "0.13.5", default-features = false }
 
 #pbs-tools = { path = "../pbs-tools" }
index 6121f7bcbccbdfdeba60b2bd34d676145b6095d8..036645d7145f8c21f8d458d1c375cab93c9c1ddf 100644 (file)
@@ -16,7 +16,7 @@ serde_json = "1.0"
 tokio = { version = "1.6", features = [ "rt", "rt-multi-thread" ] }
 
 pathpatterns = "0.1.2"
-proxmox = { version = "0.13.4", default-features = false, features = [] }
+proxmox = { version = "0.13.5", default-features = false, features = [] }
 pxar = { version = "0.10.1", features = [ "tokio-io" ] }
 
 pbs-client = { path = "../pbs-client" }