Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
refactor(api): type webhook data extraction with RawWebhookDataDict TypedDict (#34486)
YBoy9a6222f245ac
diff --git a/api/controllers/trigger/webhook.py b/api/controllers/trigger/webhook.pyindex eb579da5d4d..213704383c3 100644--- a/api/controllers/trigger/webhook.py+++ b/api/controllers/trigger/webhook.py@@ -7,7 +7,7 @@ from werkzeug.exceptions import NotFound, RequestEntityTooLargefrom controllers.trigger import bpfrom core.trigger.debug.event_bus import TriggerDebugEventBusfrom core.trigger.debug.events import WebhookDebugEvent, build_webhook_pool_key-from services.trigger.webhook_service import WebhookService+from services.trigger.webhook_service import RawWebhookDataDict, WebhookServicelogger = logging.getLogger(__name__)@@ -23,6 +23,7 @@ def _prepare_webhook_execution(webhook_id: str, is_debug: bool = False):webhook_id, is_debug=is_debug)+ webhook_data: RawWebhookDataDicttry:# Use new unified extraction and validationwebhook_data = WebhookService.extract_and_validate_webhook_data(webhook_trigger, node_config)diff --git a/api/services/trigger/webhook_service.py b/api/services/trigger/webhook_service.pyindex c03275497d7..e2d14c49e5e 100644--- a/api/services/trigger/webhook_service.py+++ b/api/services/trigger/webhook_service.py@@ -3,7 +3,7 @@ import loggingimport mimetypesimport secretsfrom collections.abc import Callable, Mapping, Sequence-from typing import Any+from typing import Any, TypedDictimport orjsonfrom flask import request@@ -50,6 +50,14 @@ logger = logging.getLogger(__name__)_file_access_controller = DatabaseFileAccessController()+class RawWebhookDataDict(TypedDict):+ method: str+ headers: dict[str, str]+ query_params: dict[str, str]+ body: dict[str, Any]+ files: dict[str, Any]++class WebhookService:"""Service for handling webhook operations."""@@ -145,7 +153,7 @@ class WebhookService:@classmethoddef extract_and_validate_webhook_data(cls, webhook_trigger: WorkflowWebhookTrigger, node_config: NodeConfigDict- ) -> dict[str, Any]:+ ) -> RawWebhookDataDict:"""Extract and validate webhook data in a single unified process.Args:@@ -173,7 +181,7 @@ class WebhookService:return processed_data@classmethod- def extract_webhook_data(cls, webhook_trigger: WorkflowWebhookTrigger) -> dict[str, Any]:+ def extract_webhook_data(cls, webhook_trigger: WorkflowWebhookTrigger) -> RawWebhookDataDict:"""Extract raw data from incoming webhook request without type conversion.Args:@@ -189,7 +197,7 @@ class WebhookService:"""cls._validate_content_length()- data = {+ data: RawWebhookDataDict = {"method": request.method,"headers": dict(request.headers),"query_params": dict(request.args),@@ -223,7 +231,7 @@ class WebhookService:return data@classmethod- def _process_and_validate_data(cls, raw_data: dict[str, Any], node_data: WebhookData) -> dict[str, Any]:+ def _process_and_validate_data(cls, raw_data: RawWebhookDataDict, node_data: WebhookData) -> RawWebhookDataDict:"""Process and validate webhook data according to node configuration.Args:@@ -664,7 +672,7 @@ class WebhookService:raise ValueError(f"Required header missing: {header_name}")@classmethod- def _validate_http_metadata(cls, webhook_data: dict[str, Any], node_data: WebhookData) -> dict[str, Any]:+ def _validate_http_metadata(cls, webhook_data: RawWebhookDataDict, node_data: WebhookData) -> dict[str, Any]:"""Validate HTTP method and content-type.Args:@@ -729,7 +737,7 @@ class WebhookService:return False@classmethod- def build_workflow_inputs(cls, webhook_data: dict[str, Any]) -> dict[str, Any]:+ def build_workflow_inputs(cls, webhook_data: RawWebhookDataDict) -> dict[str, Any]:"""Construct workflow inputs payload from webhook data.Args:@@ -747,7 +755,7 @@ class WebhookService:@classmethoddef trigger_workflow_execution(- cls, webhook_trigger: WorkflowWebhookTrigger, webhook_data: dict[str, Any], workflow: Workflow+ cls, webhook_trigger: WorkflowWebhookTrigger, webhook_data: RawWebhookDataDict, workflow: Workflow) -> None:"""Trigger workflow execution via AsyncWorkflowService.