Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion node-graph/graph-craft/src/document/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ macro_rules! tagged_value {
ContextFeatures(ContextFeatures),
#[serde(skip)]
EditorApi(Arc<PlatformEditorApi>),
/// Only used by the `resource` node, should never be serialized
#[serde(skip)]
ResourceHash(graphene_application_io::resource::ResourceHash),
Comment on lines +93 to +95

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Moving ResourceHash from the auto-generated variants to the manual non-serialized variants in the macro definition site means it is no longer included in the auto-generated match arms of try_from_any and try_from_std_any_ref.

If any part of the application attempts to downcast a dynamic ResourceHash back to a TaggedValue (which was previously supported), it will now fail with a conversion error.

To prevent this regression, please add ResourceHash to the manual non-serialized variants handling in both try_from_any and try_from_std_any_ref:

// In try_from_any (around line 276):
x if x == TypeId::of::<graphene_application_io::resource::ResourceHash>() => Ok(TaggedValue::ResourceHash(*downcast(input).unwrap())),

// In try_from_std_any_ref (around line 298):
x if x == TypeId::of::<graphene_application_io::resource::ResourceHash>() => Ok(TaggedValue::ResourceHash(*input.downcast_ref().unwrap())),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Missing ResourceHash arm in try_from_std_any_ref. Same root cause as try_from_any — downcast from std::any::Any will fail at runtime.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At node-graph/graph-craft/src/document/value.rs, line 95:

<comment>Missing `ResourceHash` arm in `try_from_std_any_ref`. Same root cause as `try_from_any` — downcast from `std::any::Any` will fail at runtime.</comment>

<file context>
@@ -90,6 +90,9 @@ macro_rules! tagged_value {
 			EditorApi(Arc<PlatformEditorApi>),
+			/// Only used by the `resource` node, should never be serialized
+			#[serde(skip)]
+			ResourceHash(graphene_application_io::resource::ResourceHash),
 		}
 
</file context>

}

impl CacheHash for TaggedValue {
Expand Down Expand Up @@ -117,6 +120,7 @@ macro_rules! tagged_value {
Self::ContextFeatures(features) => features.cache_hash(state),
Self::RenderOutput(x) => x.cache_hash(state),
Self::EditorApi(x) => x.cache_hash(state),
Self::ResourceHash(x) => x.cache_hash(state),
}
}
}
Expand Down Expand Up @@ -170,6 +174,7 @@ macro_rules! tagged_value {
Self::DocumentNode(node) => Box::new(node),
Self::ContextFeatures(features) => Box::new(features),
Self::EditorApi(x) => Box::new(x),
Self::ResourceHash(x) => Box::new(x),
}
}

Expand Down Expand Up @@ -219,6 +224,7 @@ macro_rules! tagged_value {
Self::DocumentNode(node) => Arc::new(node),
Self::ContextFeatures(features) => Arc::new(features),
Self::EditorApi(x) => Arc::new(x),
Self::ResourceHash(x) => Arc::new(x),
}
}

Expand Down Expand Up @@ -246,6 +252,7 @@ macro_rules! tagged_value {
Self::DocumentNode(_) => concrete!(DocumentNode),
Self::ContextFeatures(_) => concrete!(ContextFeatures),
Self::EditorApi(_) => concrete!(&PlatformEditorApi),
Self::ResourceHash(_) => concrete!(graphene_application_io::resource::ResourceHash),
}
}

Expand Down Expand Up @@ -351,6 +358,7 @@ macro_rules! tagged_value {
Self::DocumentNode(node) => format!("DocumentNode({node:?})"),
Self::ContextFeatures(features) => format!("ContextFeatures({features:?})"),
Self::EditorApi(_) => "PlatformEditorApi".to_string(),
Self::ResourceHash(hash) => format!("ResourceHash({hash:?})"),
}
}
}
Expand Down Expand Up @@ -397,7 +405,6 @@ tagged_value! {
VectorModification(Box<VectorModification>),
ImageData(Image<Color>),
Resource(graphene_application_io::resource::ResourceId),
ResourceHash(graphene_application_io::resource::ResourceHash),
// ==========
// ENUM TYPES
// ==========
Expand Down
Loading