Skip to content

Commit 4ce9a54

Browse files
committed
fix(codec): decode zerompk Value format before JsonValue fallback
The response codec's payload_to_json_string helper tried JsonValue msgpack first, which failed for payloads encoded with value_to_msgpack (canonical Value::Object format used by FieldGet and constant results). Add a Value-format decode attempt before falling back to the JsonValue path.
1 parent 6c59d75 commit 4ce9a54

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

nodedb/src/data/executor/response_codec.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,15 @@ pub fn decode_payload_to_json(payload: &[u8]) -> String {
367367
return String::from_utf8_lossy(payload).into_owned();
368368
}
369369

370-
// Try MessagePack → JSON.
370+
// Try zerompk Value format first (canonical internal format, used by
371+
// FieldGet, row_to_msgpack, and other direct-encode paths).
372+
if let Ok(value) = nodedb_types::value_from_msgpack(payload) {
373+
let json: serde_json::Value = value.into();
374+
return sonic_rs::to_string(&json)
375+
.unwrap_or_else(|_| String::from_utf8_lossy(payload).into_owned());
376+
}
377+
378+
// Fall back to JsonValue msgpack format (used by json_to_msgpack / encode_json).
371379
match nodedb_types::json_from_msgpack(payload) {
372380
Ok(value) => sonic_rs::to_string(&value)
373381
.unwrap_or_else(|_| String::from_utf8_lossy(payload).into_owned()),

0 commit comments

Comments
 (0)