codex: sort guardian action json (#13593)

This commit is contained in:
Ahmed Ibrahim
2026-03-07 10:50:19 -08:00
parent 5fd9f40810
commit 6cadc1e883
2 changed files with 26 additions and 4 deletions
+6 -4
View File
@@ -664,12 +664,14 @@ fn truncate_guardian_action_value(value: Value) -> Value {
.map(truncate_guardian_action_value)
.collect::<Vec<_>>(),
),
Value::Object(values) => Value::Object(
values
Value::Object(values) => {
let mut entries = values
.into_iter()
.map(|(key, value)| (key, truncate_guardian_action_value(value)))
.collect(),
),
.collect::<Vec<_>>();
entries.sort_by(|(left, _), (right, _)| left.cmp(right));
Value::Object(entries.into_iter().collect())
}
other => other,
}
}
+20
View File
@@ -169,8 +169,28 @@ fn format_guardian_action_pretty_truncates_large_string_fields() {
.as_str()
.expect("test patch should serialize as a string");
let change_count_index = rendered
.find("\"change_count\"")
.expect("rendered json should contain change_count");
let cwd_index = rendered
.find("\"cwd\"")
.expect("rendered json should contain cwd");
let files_index = rendered
.find("\"files\"")
.expect("rendered json should contain files");
let patch_index = rendered
.find("\"patch\"")
.expect("rendered json should contain patch");
let tool_index = rendered
.find("\"tool\"")
.expect("rendered json should contain tool");
assert!(rendered.contains("\"tool\": \"apply_patch\""));
assert!(rendered.len() < original_patch.len());
assert!(change_count_index < cwd_index);
assert!(cwd_index < files_index);
assert!(files_index < patch_index);
assert!(patch_index < tool_index);
}
#[test]