fix(usda): tolerate unknown prim metadata fields#95
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Relaxes USDA parsing to tolerate unknown prim metadata keys (e.g., DCC/Omniverse hints like hide_in_stage_window, no_delete) instead of failing the parse, storing them on the spec to match Pixar's behavior of preserving unrecognized metadata.
Changes:
- Replace
bail!on unknown prim metadata identifiers with a fallback that parses the value and adds it to the spec (rejecting onlylistOp-qualified unknown fields). - Add a regression test (
parse_tolerates_unknown_prim_metadata) covering bool-like tokens, strings, and ints under several non-standard identifiers.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1035
to
+1044
| other => { | ||
| ensure!( | ||
| list_op.is_none(), | ||
| "list ops are not supported for unknown prim metadata: {other}" | ||
| ); | ||
| let value = self | ||
| .parse_property_metadata_value() | ||
| .with_context(|| format!("Unable to parse prim metadata value for {other}"))?; | ||
| spec.add(other, value); | ||
| } |
Comment on lines
+1040
to
+1041
| let value = self | ||
| .parse_property_metadata_value() |
Comment on lines
+3166
to
+3170
| assert_eq!( | ||
| spec.get("hide_in_stage_window"), | ||
| Some(&sdf::Value::Token("false".into())) | ||
| ); | ||
| assert_eq!(spec.get("no_delete"), Some(&sdf::Value::Token("true".into()))); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The USDA parser rejected any prim-metadata field it didn't recognize, but Sdf accepts arbitrary identifier-keyed fields in the
( … )block and preserves the unrecognized ones. So real-world layers (Omniverse authorshide_in_stage_window,no_delete; DCCs add their own) fail to parse.Now unknown prim metadata is parsed and stashed on the spec instead of erroring - known fields are unchanged. Lets these layers load through
Stage::openwithout a pre-strip pass.