From 84e708328b6aa60e3611b2566bb7dde658ba21f0 Mon Sep 17 00:00:00 2001 From: Will Miao Date: Sun, 26 Jul 2026 10:34:20 +0800 Subject: [PATCH] fix: correct return_types propagation to GenericNodeExtractor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two bugs prevented type-signature-based fallback from working: - metadata_hook.py used getattr(obj.__class__, 'RETURN_TYPES') which fails when _async_map_node_over_list is called with a class (not instance) — obj.__class__ is the metaclass 'type', which has no RETURN_TYPES. Fixed: getattr(obj, ...). - metadata_registry.py used type(extractor) is GenericNodeExtractor to dispatch return_types. NODE_EXTRACTORS stores class references, not instances; type(Class) is always 'type', never the class. Fixed: extractor is GenericNodeExtractor. --- py/metadata_collector/metadata_hook.py | 8 ++++---- py/metadata_collector/metadata_registry.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/py/metadata_collector/metadata_hook.py b/py/metadata_collector/metadata_hook.py index f1931f7c..b9b40e09 100644 --- a/py/metadata_collector/metadata_hook.py +++ b/py/metadata_collector/metadata_hook.py @@ -83,7 +83,7 @@ class MetadataHook: # Record inputs before execution if node_id is not None: - return_types = getattr(obj.__class__, 'RETURN_TYPES', None) + return_types = getattr(obj, 'RETURN_TYPES', None) registry.record_node_execution(node_id, class_type, input_data_all, None, return_types=return_types) except Exception as e: logger.error(f"Error collecting metadata (pre-execution): {str(e)}") @@ -115,7 +115,7 @@ class MetadataHook: # Record outputs after execution if node_id is not None: - return_types = getattr(obj.__class__, 'RETURN_TYPES', None) + return_types = getattr(obj, 'RETURN_TYPES', None) registry.update_node_execution(node_id, class_type, results, return_types=return_types) except Exception as e: logger.error(f"Error collecting metadata (post-execution): {str(e)}") @@ -168,7 +168,7 @@ class MetadataHook: class_type = obj.__class__.__name__ node_id = unique_id if node_id is not None: - return_types = getattr(obj.__class__, 'RETURN_TYPES', None) + return_types = getattr(obj, 'RETURN_TYPES', None) registry.record_node_execution(node_id, class_type, input_data_all, None, return_types=return_types) except Exception as e: logger.error(f"Error collecting metadata (pre-execution): {str(e)}") @@ -186,7 +186,7 @@ class MetadataHook: class_type = obj.__class__.__name__ node_id = unique_id if node_id is not None: - return_types = getattr(obj.__class__, 'RETURN_TYPES', None) + return_types = getattr(obj, 'RETURN_TYPES', None) registry.update_node_execution(node_id, class_type, results, return_types=return_types) except Exception as e: logger.error(f"Error collecting metadata (post-execution): {str(e)}") diff --git a/py/metadata_collector/metadata_registry.py b/py/metadata_collector/metadata_registry.py index e8caa4e2..856771b1 100644 --- a/py/metadata_collector/metadata_registry.py +++ b/py/metadata_collector/metadata_registry.py @@ -172,7 +172,7 @@ class MetadataRegistry: # Extract node-specific metadata extractor = NODE_EXTRACTORS.get(class_type, GenericNodeExtractor) - if type(extractor) is GenericNodeExtractor: + if extractor is GenericNodeExtractor: extractor.extract(node_id, processed_inputs, outputs, self.prompt_metadata[self.current_prompt_id], return_types=return_types) @@ -194,7 +194,7 @@ class MetadataRegistry: # Use the same extractor to update with outputs extractor = NODE_EXTRACTORS.get(class_type, GenericNodeExtractor) if hasattr(extractor, "update"): - if type(extractor) is GenericNodeExtractor: + if extractor is GenericNodeExtractor: extractor.update( node_id, processed_outputs, self.prompt_metadata[self.current_prompt_id],