From 5442c02f67f89f07050e919b50fc788e7d40faf9 Mon Sep 17 00:00:00 2001 From: Joe Date: Fri, 6 Feb 2026 19:20:16 -0600 Subject: [PATCH] Enhance redaction handling and update snapshot references - Added support for redacting tagged values in the `RedactionMap` implementation, ensuring that nested tagged values are processed correctly. - Updated multiple snapshot files to replace specific reference IDs with deterministic `id-N` values, improving consistency across tests and snapshots. - Refactored internment logic in `internable.rs` to include variant references, ensuring proper redaction of property values in snapshots. --- crates/rojo-insta-ext/src/redaction_map.rs | 3 +++ ...d__tests__serve__meshpart_with_id_all.snap | 2 +- ...d__tests__serve__ref_properties_all-2.snap | 10 +++---- ...end__tests__serve__ref_properties_all.snap | 8 +++--- ...ve__ref_properties_patch_update_all-2.snap | 8 +++--- ...erve__ref_properties_patch_update_all.snap | 8 +++--- ...s__serve__ref_properties_remove_all-2.snap | 2 +- ...sts__serve__ref_properties_remove_all.snap | 2 +- ...ests__serve__ref_properties_subscribe.snap | 2 +- src/cli/clone.rs | 14 +++------- tests/rojo_test/internable.rs | 27 ++++++++++++++++++- 11 files changed, 53 insertions(+), 33 deletions(-) diff --git a/crates/rojo-insta-ext/src/redaction_map.rs b/crates/rojo-insta-ext/src/redaction_map.rs index 7f51775e..395c2778 100644 --- a/crates/rojo-insta-ext/src/redaction_map.rs +++ b/crates/rojo-insta-ext/src/redaction_map.rs @@ -79,6 +79,9 @@ impl RedactionMap { *mapping = new_map; } + Value::Tagged(tagged) => { + self.redact(&mut tagged.value); + } _ => {} } } diff --git a/rojo-test/serve-test-snapshots/end_to_end__tests__serve__meshpart_with_id_all.snap b/rojo-test/serve-test-snapshots/end_to_end__tests__serve__meshpart_with_id_all.snap index 48871d6e..f27092ae 100644 --- a/rojo-test/serve-test-snapshots/end_to_end__tests__serve__meshpart_with_id_all.snap +++ b/rojo-test/serve-test-snapshots/end_to_end__tests__serve__meshpart_with_id_all.snap @@ -38,7 +38,7 @@ instances: Attributes: "!Attributes": {} Value: - "!Ref": 9893f640faccb9150197026b0ca91712 + "!Ref": id-5 id-5: Children: [] ClassName: MeshPart diff --git a/rojo-test/serve-test-snapshots/end_to_end__tests__serve__ref_properties_all-2.snap b/rojo-test/serve-test-snapshots/end_to_end__tests__serve__ref_properties_all-2.snap index 9af0526c..6db1d4a5 100644 --- a/rojo-test/serve-test-snapshots/end_to_end__tests__serve__ref_properties_all-2.snap +++ b/rojo-test/serve-test-snapshots/end_to_end__tests__serve__ref_properties_all-2.snap @@ -15,7 +15,7 @@ instances: Attributes: "!Attributes": {} Value: - "!Ref": a014b12bf90014847f564374c73a5f38 + "!Ref": id-9 id-11: Children: [] ClassName: Model @@ -30,7 +30,7 @@ instances: NeedsPivotMigration: "!Bool": false PrimaryPart: - "!Ref": a014b12bf90014847f564374c73a5f38 + "!Ref": id-9 id-2: Children: - id-3 @@ -68,7 +68,7 @@ instances: Attributes: "!Attributes": {} Value: - "!Ref": 4d3455270f6618409e7d40dbcad9e25b + "!Ref": id-5 id-5: Children: - id-6 @@ -91,7 +91,7 @@ instances: Attributes: "!Attributes": {} Value: - "!Ref": 4d3455270f6618409e7d40dbcad9e25b + "!Ref": id-5 id-7: Children: - id-8 @@ -119,7 +119,7 @@ instances: NeedsPivotMigration: "!Bool": false PrimaryPart: - "!Ref": 4536e7ddde75409951458987be6ccfb5 + "!Ref": id-7 id-9: Children: - id-10 diff --git a/rojo-test/serve-test-snapshots/end_to_end__tests__serve__ref_properties_all.snap b/rojo-test/serve-test-snapshots/end_to_end__tests__serve__ref_properties_all.snap index e77712b4..73ae2af5 100644 --- a/rojo-test/serve-test-snapshots/end_to_end__tests__serve__ref_properties_all.snap +++ b/rojo-test/serve-test-snapshots/end_to_end__tests__serve__ref_properties_all.snap @@ -15,7 +15,7 @@ instances: Attributes: "!Attributes": {} Value: - "!Ref": a014b12bf90014847f564374c73a5f38 + "!Ref": id-9 id-2: Children: - id-3 @@ -53,7 +53,7 @@ instances: Attributes: "!Attributes": {} Value: - "!Ref": 4d3455270f6618409e7d40dbcad9e25b + "!Ref": id-5 id-5: Children: - id-6 @@ -76,7 +76,7 @@ instances: Attributes: "!Attributes": {} Value: - "!Ref": 4d3455270f6618409e7d40dbcad9e25b + "!Ref": id-5 id-7: Children: - id-8 @@ -101,7 +101,7 @@ instances: NeedsPivotMigration: "!Bool": false PrimaryPart: - "!Ref": 4536e7ddde75409951458987be6ccfb5 + "!Ref": id-7 id-9: Children: - id-10 diff --git a/rojo-test/serve-test-snapshots/end_to_end__tests__serve__ref_properties_patch_update_all-2.snap b/rojo-test/serve-test-snapshots/end_to_end__tests__serve__ref_properties_patch_update_all-2.snap index 03c867cf..74c22e72 100644 --- a/rojo-test/serve-test-snapshots/end_to_end__tests__serve__ref_properties_patch_update_all-2.snap +++ b/rojo-test/serve-test-snapshots/end_to_end__tests__serve__ref_properties_patch_update_all-2.snap @@ -15,7 +15,7 @@ instances: Attributes: "!Attributes": {} Value: - "!Ref": a2c2197b7d6e19e64b8991926744f3a6 + "!Ref": id-9 id-2: Children: - id-3 @@ -53,7 +53,7 @@ instances: Attributes: "!Attributes": {} Value: - "!Ref": 75d2ce9353a6c62f29130f18c35c89ce + "!Ref": id-5 id-5: Children: - id-6 @@ -76,7 +76,7 @@ instances: Attributes: "!Attributes": {} Value: - "!Ref": 75d2ce9353a6c62f29130f18c35c89ce + "!Ref": id-5 id-7: Children: - id-8 @@ -101,7 +101,7 @@ instances: NeedsPivotMigration: "!Bool": false PrimaryPart: - "!Ref": 103b2053eb8c4ea0a65500d5c20bd84f + "!Ref": id-7 Scale: "!Float32": 1 id-9: diff --git a/rojo-test/serve-test-snapshots/end_to_end__tests__serve__ref_properties_patch_update_all.snap b/rojo-test/serve-test-snapshots/end_to_end__tests__serve__ref_properties_patch_update_all.snap index 0d614977..73ae2af5 100644 --- a/rojo-test/serve-test-snapshots/end_to_end__tests__serve__ref_properties_patch_update_all.snap +++ b/rojo-test/serve-test-snapshots/end_to_end__tests__serve__ref_properties_patch_update_all.snap @@ -15,7 +15,7 @@ instances: Attributes: "!Attributes": {} Value: - "!Ref": a2c2197b7d6e19e64b8991926744f3a6 + "!Ref": id-9 id-2: Children: - id-3 @@ -53,7 +53,7 @@ instances: Attributes: "!Attributes": {} Value: - "!Ref": 75d2ce9353a6c62f29130f18c35c89ce + "!Ref": id-5 id-5: Children: - id-6 @@ -76,7 +76,7 @@ instances: Attributes: "!Attributes": {} Value: - "!Ref": 75d2ce9353a6c62f29130f18c35c89ce + "!Ref": id-5 id-7: Children: - id-8 @@ -101,7 +101,7 @@ instances: NeedsPivotMigration: "!Bool": false PrimaryPart: - "!Ref": 103b2053eb8c4ea0a65500d5c20bd84f + "!Ref": id-7 id-9: Children: - id-10 diff --git a/rojo-test/serve-test-snapshots/end_to_end__tests__serve__ref_properties_remove_all-2.snap b/rojo-test/serve-test-snapshots/end_to_end__tests__serve__ref_properties_remove_all-2.snap index a79506bc..041ef22f 100644 --- a/rojo-test/serve-test-snapshots/end_to_end__tests__serve__ref_properties_remove_all-2.snap +++ b/rojo-test/serve-test-snapshots/end_to_end__tests__serve__ref_properties_remove_all-2.snap @@ -25,6 +25,6 @@ instances: Attributes: "!Attributes": {} Value: - "!Ref": ca113df936e8659c00936176b40b02ae + "!Ref": id-4 messageCursor: 1 sessionId: id-1 diff --git a/rojo-test/serve-test-snapshots/end_to_end__tests__serve__ref_properties_remove_all.snap b/rojo-test/serve-test-snapshots/end_to_end__tests__serve__ref_properties_remove_all.snap index 80309891..1e6898bc 100644 --- a/rojo-test/serve-test-snapshots/end_to_end__tests__serve__ref_properties_remove_all.snap +++ b/rojo-test/serve-test-snapshots/end_to_end__tests__serve__ref_properties_remove_all.snap @@ -26,7 +26,7 @@ instances: Attributes: "!Attributes": {} Value: - "!Ref": ca113df936e8659c00936176b40b02ae + "!Ref": id-4 id-4: Children: [] ClassName: ObjectValue diff --git a/rojo-test/serve-test-snapshots/end_to_end__tests__serve__ref_properties_subscribe.snap b/rojo-test/serve-test-snapshots/end_to_end__tests__serve__ref_properties_subscribe.snap index 826732e0..ac14c9f4 100644 --- a/rojo-test/serve-test-snapshots/end_to_end__tests__serve__ref_properties_subscribe.snap +++ b/rojo-test/serve-test-snapshots/end_to_end__tests__serve__ref_properties_subscribe.snap @@ -20,7 +20,7 @@ body: NeedsPivotMigration: "!Bool": false PrimaryPart: - "!Ref": a014b12bf90014847f564374c73a5f38 + "!Ref": id-9 removed: [] updated: - changedClassName: ~ diff --git a/src/cli/clone.rs b/src/cli/clone.rs index 9b1bdf86..a97dfa6a 100644 --- a/src/cli/clone.rs +++ b/src/cli/clone.rs @@ -124,9 +124,7 @@ fn fetch_experience_name(place_id: u64) -> anyhow::Result { let client = Client::new(); // Place ID -> Universe ID - let universe_url = format!( - "https://apis.roblox.com/universes/v1/places/{place_id}/universe" - ); + let universe_url = format!("https://apis.roblox.com/universes/v1/places/{place_id}/universe"); let universe: UniverseResponse = client .get(&universe_url) .send() @@ -203,18 +201,12 @@ mod tests { #[test] fn sanitize_brackets_and_parens() { - assert_eq!( - sanitize_name("My Game (UPDATE) [v2.0]"), - "my-game" - ); + assert_eq!(sanitize_name("My Game (UPDATE) [v2.0]"), "my-game"); } #[test] fn sanitize_emojis() { - assert_eq!( - sanitize_name("Cool Game 🌊🏃⚡"), - "cool-game" - ); + assert_eq!(sanitize_name("Cool Game 🌊🏃⚡"), "cool-game"); } #[test] diff --git a/tests/rojo_test/internable.rs b/tests/rojo_test/internable.rs index 31f97fb9..f5ab9a4c 100644 --- a/tests/rojo_test/internable.rs +++ b/tests/rojo_test/internable.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use rbx_dom_weak::types::Ref; +use rbx_dom_weak::types::{Ref, Variant}; use serde::Serialize; use librojo::web_api::{ @@ -38,6 +38,7 @@ impl Internable for ReadResponse<'_> { redactions.intern(root_id); let root_instance = self.instances.get(&root_id).unwrap(); + intern_variant_refs(redactions, root_instance.properties.values().map(|v| v.as_ref())); for &child_id in root_instance.children.iter() { self.intern(redactions, child_id); @@ -49,6 +50,8 @@ impl<'a> Internable<&'a HashMap>> for Instance<'a> { fn intern(&self, redactions: &mut RedactionMap, other_instances: &HashMap>) { redactions.intern(self.id); + intern_variant_refs(redactions, self.properties.values().map(|v| v.as_ref())); + for child_id in self.children.iter() { let child = &other_instances[child_id]; child.intern(redactions, other_instances); @@ -77,6 +80,13 @@ impl Internable<()> for MessagesPacket<'_> { fn intern_instance_updates(redactions: &mut RedactionMap, updates: &[InstanceUpdate]) { for update in updates { redactions.intern(update.id); + intern_variant_refs( + redactions, + update + .changed_properties + .values() + .filter_map(|v| v.as_ref()), + ); } } @@ -109,3 +119,18 @@ fn intern_instance_additions( additions[root_id].intern(redactions, additions); } } + +/// Scan property values for Ref variants and intern them so they get redacted +/// to deterministic `id-N` values in snapshots. +fn intern_variant_refs<'a>( + redactions: &mut RedactionMap, + properties: impl Iterator, +) { + for variant in properties { + if let Variant::Ref(r) = variant { + if !r.is_none() { + redactions.intern(*r); + } + } + } +}