mirror of
https://github.com/openai/codex.git
synced 2026-11-11 21:10:39 +00:00
## What changed Replace the custom recursive JSON canonicalizer with `serde_json::Value::sort_all_objects()` before hashing configuration values, preserving existing fingerprints. ## Testing Add a regression test that checks reordered keys in nested tables and tables inside arrays produce the same existing fingerprint. GitOrigin-RevId: 890e79865a1d690adea3b35f19fcc6c30dbd17ce
27 lines
659 B
Rust
27 lines
659 B
Rust
//! Protects fingerprint bytes when nested configuration keys are reordered.
|
|
|
|
use super::version_for_toml;
|
|
use pretty_assertions::assert_eq;
|
|
|
|
#[test]
|
|
fn fingerprint_preserves_nested_key_order_independence_and_existing_hash() {
|
|
for input in [
|
|
r#"rows = [{ z = 2, a = 1 }, { z = 4, a = 3 }]
|
|
[nested]
|
|
z = "text"
|
|
a = true
|
|
"#,
|
|
r#"rows = [{ a = 1, z = 2 }, { a = 3, z = 4 }]
|
|
[nested]
|
|
a = true
|
|
z = "text"
|
|
"#,
|
|
] {
|
|
let value = toml::from_str(input).expect("valid config");
|
|
assert_eq!(
|
|
version_for_toml(&value),
|
|
"sha256:a5e4c8fbdbc75d185b0f2b5291bfb2de10e8c523d6c89248876fd78a97c83176"
|
|
);
|
|
}
|
|
}
|