all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH proxmox] schema: ser: fix value serialization for maps
@ 2026-03-26 16:46 Christoph Heiss
  2026-03-27 15:24 ` Wolfgang Bumiller
  0 siblings, 1 reply; 2+ messages in thread
From: Christoph Heiss @ 2026-03-26 16:46 UTC (permalink / raw)
  To: pve-devel

.. by actually serializing map values as values, not keys.

Call the correct .do_value() instead of .do_key() in
SerializeStruct::serialize_value().

Without, the included test case would produce "a=,1=" instead of the
expected "a=1"

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
 proxmox-schema/src/property_string.rs | 17 +++++++++++++++++
 proxmox-schema/src/ser/mod.rs         |  2 +-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/proxmox-schema/src/property_string.rs b/proxmox-schema/src/property_string.rs
index 6e4b3248..fc52c895 100644
--- a/proxmox-schema/src/property_string.rs
+++ b/proxmox-schema/src/property_string.rs
@@ -367,6 +367,7 @@ where
 #[cfg(test)]
 mod test {
     use serde::{Deserialize, Serialize};
+    use std::collections::HashMap;
 
     use crate::schema::*;
 
@@ -515,4 +516,20 @@ mod test {
 
         Ok(())
     }
+
+    #[test]
+    fn test_map_serialization() {
+        #[derive(Serialize, PartialEq)]
+        struct Outer(HashMap<String, u32>);
+
+        impl ApiType for Outer {
+            const API_SCHEMA: Schema = ObjectSchema::new("Outer", &[])
+                .additional_properties(true)
+                .schema();
+        }
+
+        let mut map = HashMap::with_capacity(2);
+        map.insert("a".to_owned(), 1);
+        assert_eq!(super::print(&Outer(map)).expect("property string"), "a=1");
+    }
 }
diff --git a/proxmox-schema/src/ser/mod.rs b/proxmox-schema/src/ser/mod.rs
index e19209a8..0a91b13c 100644
--- a/proxmox-schema/src/ser/mod.rs
+++ b/proxmox-schema/src/ser/mod.rs
@@ -284,7 +284,7 @@ impl<T: fmt::Write> ser::SerializeMap for SerializeStruct<T> {
     where
         V: Serialize + ?Sized,
     {
-        self.do_key(value)
+        self.do_value(value)
     }
 
     fn end(self) -> Result<Self::Ok, Self::Error> {
-- 
2.53.0





^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH proxmox] schema: ser: fix value serialization for maps
  2026-03-26 16:46 [PATCH proxmox] schema: ser: fix value serialization for maps Christoph Heiss
@ 2026-03-27 15:24 ` Wolfgang Bumiller
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Bumiller @ 2026-03-27 15:24 UTC (permalink / raw)
  To: pve-devel, Christoph Heiss

On Thu, 26 Mar 2026 17:46:30 +0100, Christoph Heiss wrote:
> schema: ser: fix value serialization for maps

Applied, thanks!

[1/1] schema: ser: fix value serialization for maps
      commit: 36810334ed1ade0c8a81ad61bfd33ec294fac6c1





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-27 15:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-26 16:46 [PATCH proxmox] schema: ser: fix value serialization for maps Christoph Heiss
2026-03-27 15:24 ` Wolfgang Bumiller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal