feat(webhook): add variable selector to response body field#32919
feat(webhook): add variable selector to response body field#32919abesticode wants to merge 10 commits intolanggenius:mainfrom
Conversation
- Integrate InputWithVar component in trigger-webhook panel for response body
- Expose req_body_params, req_query_params, and req_header_params as selectable
variables in the webhook trigger node's own variable group
- Fix variable group structure to pass schema validation in the workflow editor
- Add _interpolate_variables to resolve {{namespace.key}} placeholders at
response time, supporting both plain and workflow-editor {{#nodeId.ns.key#}} formats
- Add docstring (Args/Returns) to _interpolate_variables for consistency
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 significantly enhances the usability of the Webhook Trigger node by introducing dynamic variable selection for its response body. Previously, users had to manually construct variable paths, which was error-prone. The changes integrate a variable selector into the frontend and implement a robust backend interpolation mechanism, allowing for seamless and dynamic customization of webhook responses based on incoming request data. 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. Changelog
Activity
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. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Pyrefly DiffNo changes detected. |
There was a problem hiding this comment.
Code Review
This pull request enhances the Webhook Trigger node by adding a variable selector to the response body field, improving usability by allowing dynamic data from the request to be easily referenced. However, the current implementation is vulnerable to JSON injection. The interpolation logic performs raw string substitution without context-aware escaping, which could allow an attacker to manipulate the JSON response structure through malicious input in the webhook request. While the backend implementation for variable interpolation is solid and frontend changes correctly integrate webhook variables, there is a minor suggestion regarding Python import conventions.
- Move import re to top-level imports per PEP 8 - Fix JSON injection in _interpolate_variables: string values are now JSON-escaped when the response body template is a JSON structure
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-03-03 14:12:42.861884680 +0000
+++ /tmp/pyrefly_pr.txt 2026-03-03 14:12:35.094896039 +0000
@@ -1272,7 +1272,7 @@
ERROR Argument `Mapping[str, str] | dict[LaxStr, LaxStr]` is not assignable to parameter `credentials` with type `Mapping[LaxStr, LaxStr]` in function `core.trigger.entities.api_entities.SubscriptionBuilderApiEntity.__init__` [bad-argument-type]
--> services/trigger/trigger_subscription_builder_service.py:385:25
ERROR Argument `dict[str, Any]` is not assignable to parameter `inputs` with type `Mapping[LaxStr, Any]` in function `services.workflow.entities.WebhookTriggerData.__init__` [bad-argument-type]
- --> services/trigger/webhook_service.py:756:28
+ --> services/trigger/webhook_service.py:757:28
ERROR Object of class `dict` has no attribute `encode`
ERROR Object of class `dict` has no attribute `encode`
ERROR Argument `Mapping[str, Any] | dict[LaxStr, Any]` is not assignable to parameter `inputs` with type `Mapping[LaxStr, Any]` in function `core.app.entities.task_entities.Data.__init__` [bad-argument-type]
|
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-03-03 14:21:40.245267112 +0000
+++ /tmp/pyrefly_pr.txt 2026-03-03 14:21:32.153198165 +0000
@@ -1272,7 +1272,7 @@
ERROR Argument `Mapping[str, str] | dict[LaxStr, LaxStr]` is not assignable to parameter `credentials` with type `Mapping[LaxStr, LaxStr]` in function `core.trigger.entities.api_entities.SubscriptionBuilderApiEntity.__init__` [bad-argument-type]
--> services/trigger/trigger_subscription_builder_service.py:385:25
ERROR Argument `dict[str, Any]` is not assignable to parameter `inputs` with type `Mapping[LaxStr, Any]` in function `services.workflow.entities.WebhookTriggerData.__init__` [bad-argument-type]
- --> services/trigger/webhook_service.py:756:28
+ --> services/trigger/webhook_service.py:757:28
ERROR Object of class `dict` has no attribute `encode`
ERROR Object of class `dict` has no attribute `encode`
ERROR Argument `Mapping[str, Any] | dict[LaxStr, Any]` is not assignable to parameter `inputs` with type `Mapping[LaxStr, Any]` in function `core.app.entities.task_entities.Data.__init__` [bad-argument-type]
|
Sort output-vars (components) before use-available-var-list (hooks) to comply with eslint import/order rule.
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-03-03 14:32:56.630973296 +0000
+++ /tmp/pyrefly_pr.txt 2026-03-03 14:32:48.458931135 +0000
@@ -1272,7 +1272,7 @@
ERROR Argument `Mapping[str, str] | dict[LaxStr, LaxStr]` is not assignable to parameter `credentials` with type `Mapping[LaxStr, LaxStr]` in function `core.trigger.entities.api_entities.SubscriptionBuilderApiEntity.__init__` [bad-argument-type]
--> services/trigger/trigger_subscription_builder_service.py:385:25
ERROR Argument `dict[str, Any]` is not assignable to parameter `inputs` with type `Mapping[LaxStr, Any]` in function `services.workflow.entities.WebhookTriggerData.__init__` [bad-argument-type]
- --> services/trigger/webhook_service.py:756:28
+ --> services/trigger/webhook_service.py:757:28
ERROR Object of class `dict` has no attribute `encode`
ERROR Object of class `dict` has no attribute `encode`
ERROR Argument `Mapping[str, Any] | dict[LaxStr, Any]` is not assignable to parameter `inputs` with type `Mapping[LaxStr, Any]` in function `core.app.entities.task_entities.Data.__init__` [bad-argument-type]
|
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-03-03 14:33:32.153869095 +0000
+++ /tmp/pyrefly_pr.txt 2026-03-03 14:33:23.371051510 +0000
@@ -1272,7 +1272,7 @@
ERROR Argument `Mapping[str, str] | dict[LaxStr, LaxStr]` is not assignable to parameter `credentials` with type `Mapping[LaxStr, LaxStr]` in function `core.trigger.entities.api_entities.SubscriptionBuilderApiEntity.__init__` [bad-argument-type]
--> services/trigger/trigger_subscription_builder_service.py:385:25
ERROR Argument `dict[str, Any]` is not assignable to parameter `inputs` with type `Mapping[LaxStr, Any]` in function `services.workflow.entities.WebhookTriggerData.__init__` [bad-argument-type]
- --> services/trigger/webhook_service.py:756:28
+ --> services/trigger/webhook_service.py:757:28
ERROR Object of class `dict` has no attribute `encode`
ERROR Object of class `dict` has no attribute `encode`
ERROR Argument `Mapping[str, Any] | dict[LaxStr, Any]` is not assignable to parameter `inputs` with type `Mapping[LaxStr, Any]` in function `core.app.entities.task_entities.Data.__init__` [bad-argument-type]
|
- Move InputWithVar (components) before useAvailableVarList (hooks) to satisfy eslint import/order rule - Remove unnecessary parentheses around type assertion on line 95
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-03-03 15:04:55.027178883 +0000
+++ /tmp/pyrefly_pr.txt 2026-03-03 15:04:45.375052942 +0000
@@ -1262,7 +1262,7 @@
ERROR Argument `Mapping[str, str] | dict[LaxStr, LaxStr]` is not assignable to parameter `credentials` with type `Mapping[LaxStr, LaxStr]` in function `core.trigger.entities.api_entities.SubscriptionBuilderApiEntity.__init__` [bad-argument-type]
--> services/trigger/trigger_subscription_builder_service.py:385:25
ERROR Argument `dict[str, Any]` is not assignable to parameter `inputs` with type `Mapping[LaxStr, Any]` in function `services.workflow.entities.WebhookTriggerData.__init__` [bad-argument-type]
- --> services/trigger/webhook_service.py:756:28
+ --> services/trigger/webhook_service.py:757:28
ERROR Object of class `dict` has no attribute `encode`
ERROR Object of class `dict` has no attribute `encode`
ERROR Argument `Mapping[str, Any] | dict[LaxStr, Any]` is not assignable to parameter `inputs` with type `Mapping[LaxStr, Any]` in function `core.app.entities.task_entities.Data.__init__` [bad-argument-type]
|
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-03-03 15:05:13.115509210 +0000
+++ /tmp/pyrefly_pr.txt 2026-03-03 15:05:05.346487236 +0000
@@ -1262,7 +1262,7 @@
ERROR Argument `Mapping[str, str] | dict[LaxStr, LaxStr]` is not assignable to parameter `credentials` with type `Mapping[LaxStr, LaxStr]` in function `core.trigger.entities.api_entities.SubscriptionBuilderApiEntity.__init__` [bad-argument-type]
--> services/trigger/trigger_subscription_builder_service.py:385:25
ERROR Argument `dict[str, Any]` is not assignable to parameter `inputs` with type `Mapping[LaxStr, Any]` in function `services.workflow.entities.WebhookTriggerData.__init__` [bad-argument-type]
- --> services/trigger/webhook_service.py:756:28
+ --> services/trigger/webhook_service.py:757:28
ERROR Object of class `dict` has no attribute `encode`
ERROR Object of class `dict` has no attribute `encode`
ERROR Argument `Mapping[str, Any] | dict[LaxStr, Any]` is not assignable to parameter `inputs` with type `Mapping[LaxStr, Any]` in function `core.app.entities.task_entities.Data.__init__` [bad-argument-type]
|
Group all _base/components/* (field, output-vars, prompt/editor, split) before _base/hooks/* (use-available-var-list) per eslint import/order rule
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-03-03 15:16:42.335441478 +0000
+++ /tmp/pyrefly_pr.txt 2026-03-03 15:16:33.013456912 +0000
@@ -1262,7 +1262,7 @@
ERROR Argument `Mapping[str, str] | dict[LaxStr, LaxStr]` is not assignable to parameter `credentials` with type `Mapping[LaxStr, LaxStr]` in function `core.trigger.entities.api_entities.SubscriptionBuilderApiEntity.__init__` [bad-argument-type]
--> services/trigger/trigger_subscription_builder_service.py:385:25
ERROR Argument `dict[str, Any]` is not assignable to parameter `inputs` with type `Mapping[LaxStr, Any]` in function `services.workflow.entities.WebhookTriggerData.__init__` [bad-argument-type]
- --> services/trigger/webhook_service.py:756:28
+ --> services/trigger/webhook_service.py:757:28
ERROR Object of class `dict` has no attribute `encode`
ERROR Object of class `dict` has no attribute `encode`
ERROR Argument `Mapping[str, Any] | dict[LaxStr, Any]` is not assignable to parameter `inputs` with type `Mapping[LaxStr, Any]` in function `core.app.entities.task_entities.Data.__init__` [bad-argument-type]
|
|
Hi @Yeuoly , I’ve submitted this PR to enhance the Webhook Trigger node by adding a variable selector for the Response Body. This should make it much easier for users to reference request data dynamically. Could you please take a look when you have a moment? I've ensured it passes schema validation and includes backend interpolation. Thanks! |
|
/gemini review |
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-03-04 21:48:26.762577061 +0000
+++ /tmp/pyrefly_pr.txt 2026-03-04 21:48:18.440601863 +0000
@@ -1262,7 +1262,7 @@
ERROR Argument `Mapping[str, str] | dict[LaxStr, LaxStr]` is not assignable to parameter `credentials` with type `Mapping[LaxStr, LaxStr]` in function `core.trigger.entities.api_entities.SubscriptionBuilderApiEntity.__init__` [bad-argument-type]
--> services/trigger/trigger_subscription_builder_service.py:385:25
ERROR Argument `dict[str, Any]` is not assignable to parameter `inputs` with type `Mapping[LaxStr, Any]` in function `services.workflow.entities.WebhookTriggerData.__init__` [bad-argument-type]
- --> services/trigger/webhook_service.py:756:28
+ --> services/trigger/webhook_service.py:757:28
ERROR Object of class `dict` has no attribute `encode`
ERROR Object of class `dict` has no attribute `encode`
ERROR Argument `Mapping[str, Any] | dict[LaxStr, Any]` is not assignable to parameter `inputs` with type `Mapping[LaxStr, Any]` in function `core.app.entities.task_entities.Data.__init__` [bad-argument-type]
|
There was a problem hiding this comment.
Code Review
This pull request successfully enhances the Webhook Trigger node by integrating a variable selector into the Response Body field. The backend now supports variable interpolation within the response body, handling both plain {{namespace.key}} and workflow-editor {{#nodeId.namespace.key#}} formats. The frontend changes correctly replace the plain textarea with an InputWithVar component and expose webhook-specific variables for selection. The overall implementation addresses the problem of manual variable entry, making the feature more user-friendly and less error-prone.
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-03-05 02:26:24.020168853 +0000
+++ /tmp/pyrefly_pr.txt 2026-03-05 02:26:16.171138632 +0000
@@ -1262,7 +1262,7 @@
ERROR Argument `Mapping[str, str] | dict[LaxStr, LaxStr]` is not assignable to parameter `credentials` with type `Mapping[LaxStr, LaxStr]` in function `core.trigger.entities.api_entities.SubscriptionBuilderApiEntity.__init__` [bad-argument-type]
--> services/trigger/trigger_subscription_builder_service.py:385:25
ERROR Argument `dict[str, Any]` is not assignable to parameter `inputs` with type `Mapping[LaxStr, Any]` in function `services.workflow.entities.WebhookTriggerData.__init__` [bad-argument-type]
- --> services/trigger/webhook_service.py:756:28
+ --> services/trigger/webhook_service.py:757:28
ERROR Object of class `dict` has no attribute `encode`
ERROR Object of class `dict` has no attribute `encode`
ERROR Argument `Mapping[str, Any] | dict[LaxStr, Any]` is not assignable to parameter `inputs` with type `Mapping[LaxStr, Any]` in function `core.app.entities.task_entities.Data.__init__` [bad-argument-type]
|
Summary
This PR enhances the Webhook Trigger node by enabling a variable selector for the Response Body field, allowing users to dynamically reference incoming request data without manually typing variable paths.
Problem
Previously, the Response Body field in the webhook trigger node was a plain text input. Users had to manually type variable placeholders (e.g.,
{{req_body_params.name}}), which was error-prone and not discoverable. Additionally, the webhook trigger's own variables (req_body_params,req_query_params,req_header_params) were not available in the workflow variable selector.Changes
InputWithVarcomponent in the trigger-webhook panel, enabling the variable selector dropdown in the Response Body field.req_body_params,req_query_params, andreq_header_paramsas a dedicated variable group within the webhook trigger node so they appear alongside system variables in the selector.{{namespace.key}}placeholders in the response body at runtime, supporting both the plain format ({{req_body_params.field}}) and the workflow-editor format ({{#nodeId.namespace.key#}}). Unresolvable placeholders are left unchanged.Args/Returnsdocstring to _interpolate_variables for consistency with the rest of the service.Screenshots
Checklist
make lintandmake type-check(backend) andcd web && npx lint-staged(frontend) to appease the lint gods