Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
fix(cli): ignore null profile envelope metadata (#2274)
Zayn Jarvisa88007b609b6
diff --git a/crates/ov_cli/src/base_client.rs b/crates/ov_cli/src/base_client.rsindex 5a0a63a84..42c33b9a9 100644--- a/crates/ov_cli/src/base_client.rs+++ b/crates/ov_cli/src/base_client.rs@@ -84,7 +84,7 @@ pub fn unwrap_success_envelope(json: Value, preserve_profile: bool) -> Value {return result.clone();}- let Some(profile) = json.get("profile") else {+ let Some(profile) = json.get("profile").filter(|profile| !profile.is_null()) else {return result.clone();};@@ -547,6 +547,26 @@ mod tests {);}+ #[test]+ fn unwrap_success_envelope_drops_null_profile_for_value_results() {+ let body = json!({+ "status": "ok",+ "result": [+ {"id": "1"}+ ],+ "profile": null+ });++ let result = unwrap_success_envelope(body, true);++ assert_eq!(+ result,+ json!([+ {"id": "1"}+ ])+ );+ }+#[test]fn unwrap_success_envelope_wraps_scalar_results_when_profile_is_preserved() {let body = json!({diff --git a/crates/ov_cli/src/output.rs b/crates/ov_cli/src/output.rsindex b8776d964..31e7339b6 100644--- a/crates/ov_cli/src/output.rs+++ b/crates/ov_cli/src/output.rs@@ -1,5 +1,5 @@use serde::Serialize;-use serde_json::json;+use serde_json::{json, Value};use unicode_width::{UnicodeWidthChar, UnicodeWidthStr};const MAX_COL_WIDTH: usize = 256;@@ -22,7 +22,7 @@ impl From<&str> for OutputFormat {pub fn output_success<T: Serialize>(result: T, format: OutputFormat, compact: bool) {if matches!(format, OutputFormat::Json) {if compact {- println!("{}", json!({ "ok": true, "result": result }));+ println!("{}", compact_success_value(result));} else {println!("{}",@@ -34,6 +34,29 @@ pub fn output_success<T: Serialize>(result: T, format: OutputFormat, compact: bo}}+fn compact_success_value<T: Serialize>(result: T) -> Value {+ let mut obj = match serde_json::to_value(result).unwrap_or(Value::Null) {+ Value::Object(obj) => obj,+ value => return json!({ "ok": true, "result": value }),+ };++ let Some(profile) = obj.remove("profile") else {+ return json!({ "ok": true, "result": Value::Object(obj) });+ };++ let result = if obj.len() == 1 && obj.contains_key("result") {+ obj.remove("result").unwrap_or(Value::Null)+ } else {+ Value::Object(obj)+ };++ if profile.is_null() {+ return json!({ "ok": true, "result": result });+ }++ json!({ "status": "ok", "result": result, "profile": profile })+}+#[allow(dead_code)]pub fn output_error(code: &str, message: &str, format: OutputFormat, compact: bool) {if matches!(format, OutputFormat::Json) && compact {@@ -978,6 +1001,82 @@ mod tests {);}+ #[test]+ fn test_compact_json_lifts_profile_next_to_result_for_list_payloads() {+ let value = json!({+ "result": [+ {"id": "1", "name": "alpha"}+ ],+ "profile": [+ "line one"+ ]+ });++ let rendered = compact_success_value(value);++ assert_eq!(+ rendered,+ json!({+ "status": "ok",+ "result": [+ {"id": "1", "name": "alpha"}+ ],+ "profile": [+ "line one"+ ]+ })+ );+ }++ #[test]+ fn test_compact_json_lifts_profile_next_to_result_for_object_payloads() {+ let value = json!({+ "healthy": true,+ "version": "0.1.x",+ "profile": [+ "line one"+ ]+ });++ let rendered = compact_success_value(value);++ assert_eq!(+ rendered,+ json!({+ "status": "ok",+ "result": {+ "healthy": true,+ "version": "0.1.x"+ },+ "profile": [+ "line one"+ ]+ })+ );+ }++ #[test]+ fn test_compact_json_treats_null_profile_as_absent() {+ let value = json!({+ "result": [+ {"id": "1", "name": "alpha"}+ ],+ "profile": null+ });++ let rendered = compact_success_value(value.clone());++ assert_eq!(+ rendered,+ json!({+ "ok": true,+ "result": [+ {"id": "1", "name": "alpha"}+ ]+ })+ );+ }+#[test]fn test_profile_section_is_not_duplicated_for_plain_object_output() {let value = json!({