fix(api): add trigger_info to WorkflowNodeExecutionMetadataKey#33753
fix(api): add trigger_info to WorkflowNodeExecutionMetadataKey#33753fatelei merged 4 commits intolanggenius:mainfrom
trigger_info to WorkflowNodeExecutionMetadataKey#33753Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refactors the handling of trigger event information within the workflow execution metadata. It introduces a new, explicit enum member for trigger details, ensuring a standardized and type-safe approach to storing this critical data. The changes improve code clarity and maintainability by removing unnecessary type casting and are backed by new unit tests to validate the correct behavior. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-03-19 09:26:28.513816537 +0000
+++ /tmp/pyrefly_pr.txt 2026-03-19 09:26:18.563694658 +0000
@@ -5249,6 +5249,8 @@
--> tests/unit_tests/core/workflow/nodes/tool/test_tool_node.py:105:22
ERROR Argument `Generator[NodeEventBase, None, LLMUsage]` is not assignable to parameter `generator` with type `Generator[Unknown]` in function `_collect_events` [bad-argument-type]
--> tests/unit_tests/core/workflow/nodes/tool/test_tool_node.py:113:32
+ERROR Cannot index into `Mapping[WorkflowNodeExecutionMetadataKey, Any]` [bad-index]
+ --> tests/unit_tests/core/workflow/nodes/trigger_plugin/test_trigger_event_node.py:59:28
ERROR Argument `dict[str, dict[str, WriteMode | list[str] | str] | str]` is not assignable to parameter `config` with type `NodeConfigDict` in function `dify_graph.nodes.variable_assigner.v1.node.VariableAssignerNode.__init__` [bad-argument-type]
--> tests/unit_tests/core/workflow/nodes/variable_assigner/v1/test_variable_assigner_v1.py:107:16
ERROR Argument `dict[str, dict[str, WriteMode | list[str] | str] | str]` is not assignable to parameter `config` with type `NodeConfigDict` in function `dify_graph.nodes.variable_assigner.v1.node.VariableAssignerNode.__init__` [bad-argument-type]
@@ -5387,6 +5389,10 @@
--> tests/unit_tests/dify_graph/model_runtime/utils/test_encoders.py:153:59
ERROR No matching overload found for function `compile` called with arguments: (Literal['abc']) [no-matching-overload]
--> tests/unit_tests/dify_graph/model_runtime/utils/test_encoders.py:181:40
+ERROR Argument `dict[str, Any]` is not assignable to parameter `metadata` with type `Mapping[WorkflowNodeExecutionMetadataKey, Any]` in function `dify_graph.node_events.base.NodeRunResult.__init__` [bad-argument-type]
+ --> tests/unit_tests/dify_graph/node_events/test_base.py:9:18
+ERROR Cannot index into `Mapping[WorkflowNodeExecutionMetadataKey, Any]` [bad-index]
+ --> tests/unit_tests/dify_graph/node_events/test_base.py:17:28
ERROR Object of class `int` has no attribute `startswith` [missing-attribute]
--> tests/unit_tests/extensions/otel/test_celery_sqlcommenter.py:25:16
ERROR Cannot index into `object` [bad-index]
|
There was a problem hiding this comment.
Code Review
This pull request refactors the metadata key for trigger information into the WorkflowNodeExecutionMetadataKey enum, which improves type safety and code consistency. The changes are well-implemented, and new tests have been added to cover them. My feedback focuses on updating the new tests to use the newly introduced enum member for better consistency with the refactoring.
api/tests/unit_tests/core/workflow/nodes/trigger_plugin/test_trigger_event_node.py
Outdated
Show resolved
Hide resolved
api/tests/unit_tests/core/workflow/nodes/trigger_plugin/test_trigger_event_node.py
Outdated
Show resolved
Hide resolved
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-03-19 09:28:27.337761361 +0000
+++ /tmp/pyrefly_pr.txt 2026-03-19 09:28:18.061753762 +0000
@@ -5249,6 +5249,8 @@
--> tests/unit_tests/core/workflow/nodes/tool/test_tool_node.py:105:22
ERROR Argument `Generator[NodeEventBase, None, LLMUsage]` is not assignable to parameter `generator` with type `Generator[Unknown]` in function `_collect_events` [bad-argument-type]
--> tests/unit_tests/core/workflow/nodes/tool/test_tool_node.py:113:32
+ERROR Cannot index into `Mapping[WorkflowNodeExecutionMetadataKey, Any]` [bad-index]
+ --> tests/unit_tests/core/workflow/nodes/trigger_plugin/test_trigger_event_node.py:59:28
ERROR Argument `dict[str, dict[str, WriteMode | list[str] | str] | str]` is not assignable to parameter `config` with type `NodeConfigDict` in function `dify_graph.nodes.variable_assigner.v1.node.VariableAssignerNode.__init__` [bad-argument-type]
--> tests/unit_tests/core/workflow/nodes/variable_assigner/v1/test_variable_assigner_v1.py:107:16
ERROR Argument `dict[str, dict[str, WriteMode | list[str] | str] | str]` is not assignable to parameter `config` with type `NodeConfigDict` in function `dify_graph.nodes.variable_assigner.v1.node.VariableAssignerNode.__init__` [bad-argument-type]
@@ -5387,6 +5389,10 @@
--> tests/unit_tests/dify_graph/model_runtime/utils/test_encoders.py:153:59
ERROR No matching overload found for function `compile` called with arguments: (Literal['abc']) [no-matching-overload]
--> tests/unit_tests/dify_graph/model_runtime/utils/test_encoders.py:181:40
+ERROR Argument `dict[str, Any]` is not assignable to parameter `metadata` with type `Mapping[WorkflowNodeExecutionMetadataKey, Any]` in function `dify_graph.node_events.base.NodeRunResult.__init__` [bad-argument-type]
+ --> tests/unit_tests/dify_graph/node_events/test_base.py:9:18
+ERROR Cannot index into `Mapping[WorkflowNodeExecutionMetadataKey, Any]` [bad-index]
+ --> tests/unit_tests/dify_graph/node_events/test_base.py:17:28
ERROR Object of class `int` has no attribute `startswith` [missing-attribute]
--> tests/unit_tests/extensions/otel/test_celery_sqlcommenter.py:25:16
ERROR Cannot index into `object` [bad-index]
|
trigger_info to WorkflowNodeExecutionMetadataKey
Pyrefly DiffNo changes detected. |
Summary
This PR fixes a
NodeRunResult.metadatavalidation failure caused by the trigger plugin node writingtrigger_infoas a metadata key before that key was registered inWorkflowNodeExecutionMetadataKey.It also removes the standalone
TRIGGER_INFO_METADATA_KEYconstant and standardizes all trigger metadata access throughWorkflowNodeExecutionMetadataKey.TRIGGER_INFO.Root Cause
NodeRunResult.metadatais validated againstWorkflowNodeExecutionMetadataKey.The trigger plugin node wrote:
trigger_infobut
WorkflowNodeExecutionMetadataKeydid not include that value yet.As a result, Pydantic rejected the metadata payload when constructing
NodeRunResult, causing workflow execution to fail for trigger plugin nodes.Changes
Fix metadata validation
TRIGGER_INFOtoWorkflowNodeExecutionMetadataKeyWorkflowNodeExecutionMetadataKey.TRIGGER_INFOStandardize metadata key usage
TRIGGER_INFO_METADATA_KEYwithWorkflowNodeExecutionMetadataKey.TRIGGER_INFOTRIGGER_INFO_METADATA_KEYconstant fromcore.trigger.constantsTests
NodeRunResultaccepts trigger metadata underWorkflowNodeExecutionMetadataKey.TRIGGER_INFOFix #33754
Screenshots
Checklist
make lintandmake type-check(backend) andcd web && npx lint-staged(frontend) to appease the lint gods