Skip to content

refactor(api): isolate native webhook runtime - #45912

Merged
hjlarry merged 29 commits into
mainfrom
hjlarry/trigger-webhook-runtime
Nov 10, 2026
Merged

hjlarry merged 29 commits into
mainfrom
hjlarry/trigger-webhook-runtime

Conversation

@hjlarry

@hjlarry hjlarry commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

part of #39993

Refactor native webhook execution into injected admission, request parsing, and workflow dispatch components. Persist webhook bindings through the existing publication transaction and keep draft bindings scoped to the owning app.

Preserve the existing webhook response and validation behavior, including request size limits and numeric parameter handling.

@github-actions github-actions Bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-11-10 03:54:45.875447172 +0000
+++ /tmp/pyrefly_pr.txt	2026-11-10 03:54:33.431366126 +0000
@@ -1010,16 +1010,6 @@
   --> tests/e2e_tests/containers/services/test_webapp_auth_service.py:45:14
 ERROR Argument `Literal['emoji']` is not assignable to parameter `icon_type` with type `IconType | SQLCoreOperations[IconType | None] | None` in function `models.model.App.__init__` [bad-argument-type]
   --> tests/e2e_tests/containers/services/test_webapp_auth_service.py:46:19
-ERROR Argument `Literal['workflow']` is not assignable to parameter `mode` with type `AppMode | SQLCoreOperations[AppMode]` in function `models.model.App.__init__` [bad-argument-type]
-  --> tests/e2e_tests/containers/services/test_webhook_service.py:62:14
-ERROR Argument `Literal['normal']` is not assignable to parameter `status` with type `SQLCoreOperations[TenantStatus] | TenantStatus` in function `models.account.Tenant.__init__` [bad-argument-type]
-  --> tests/e2e_tests/containers/services/test_webhook_service_relationships.py:69:72
-ERROR Argument `Literal['workflow']` is not assignable to parameter `mode` with type `AppMode | SQLCoreOperations[AppMode]` in function `models.model.App.__init__` [bad-argument-type]
-  --> tests/e2e_tests/containers/services/test_webhook_service_relationships.py:91:18
-ERROR Argument `Literal['emoji']` is not assignable to parameter `icon_type` with type `IconType | SQLCoreOperations[IconType | None] | None` in function `models.model.App.__init__` [bad-argument-type]
-  --> tests/e2e_tests/containers/services/test_webhook_service_relationships.py:92:23
-ERROR Class `WebhookServiceRelationshipFactory` has no class attribute `_read_cache` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_webhook_service_relationships.py:549:26
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
    --> tests/e2e_tests/containers/services/test_workflow_app_service.py:126:38
 ERROR Argument `Literal['app-run']` is not assignable to parameter `triggered_from` with type `SQLCoreOperations[WorkflowRunTriggeredFrom] | WorkflowRunTriggeredFrom` in function `models.workflow.WorkflowRun.__init__` [bad-argument-type]
@@ -1598,12 +1588,10 @@
   --> tests/e2e_tests/containers/trigger/conftest.py:65:14
 ERROR Argument `Literal['emoji']` is not assignable to parameter `icon_type` with type `IconType | SQLCoreOperations[IconType | None] | None` in function `models.model.App.__init__` [bad-argument-type]
   --> tests/e2e_tests/containers/trigger/conftest.py:66:19
-ERROR Argument `str | None` is not assignable to parameter `workflow_id` with type `SQLCoreOperations[str] | str` in function `models.trigger.WorkflowTriggerLog.__init__` [bad-argument-type]
-   --> tests/e2e_tests/containers/trigger/test_trigger_e2e.py:208:25
 ERROR Argument `dict[str, str | dict[str, str | dict[str, str]]]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `core.trigger.debug.event_selectors.TriggerDebugEventPoller.__init__` [bad-argument-type]
-   --> tests/e2e_tests/containers/trigger/test_trigger_e2e.py:310:21
+   --> tests/e2e_tests/containers/trigger/test_trigger_e2e.py:293:21
 ERROR Argument `dict[str, Any]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.schedule_service.ScheduleService.to_schedule_config` [bad-argument-type]
-   --> tests/e2e_tests/containers/trigger/test_trigger_e2e.py:611:49
+   --> tests/e2e_tests/containers/trigger/test_trigger_e2e.py:588:49
 ERROR Class member `StaticRepo.get_form` overrides parent class `HumanInputFormRepository` in an inconsistent manner [bad-override]
    --> tests/e2e_tests/contracts/core/workflow/graph_engine/test_parallel_human_input_join_resume.py:137:9
 ERROR Argument `_TestFileReferenceFactory` is not assignable to parameter `file_reference_factory` with type `DifyFileReferenceFactory | None` in function `core.workflow.nodes.human_input.callback.DifyHITLCallback.__init__` [bad-argument-type]
@@ -2698,8 +2686,6 @@
    --> tests/unit_tests/controllers/service_api/test_wraps.py:963:16
 ERROR Object of class `FromClause` has no attribute `drop` [missing-attribute]
   --> tests/unit_tests/controllers/trigger/test_trigger.py:46:5
-ERROR `_RequestStub` is not assignable to attribute `request` with type `Request` [bad-assignment]
-  --> tests/unit_tests/controllers/trigger/test_webhook.py:70:22
 ERROR Argument `None` is not assignable to parameter `type` with type `EndUserType | SQLCoreOperations[EndUserType]` in function `models.model.EndUser.__init__` [bad-argument-type]
    --> tests/unit_tests/controllers/web/test_wraps.py:387:81
 ERROR Expected 1 more positional argument [bad-argument-count]
@@ -5895,42 +5881,6 @@
   --> tests/unit_tests/services/tools/test_tools_transform_service.py:85:9
 ERROR Object of class `Mapping` has no attribute `startswith` [missing-attribute]
    --> tests/unit_tests/services/tools/test_tools_transform_service.py:819:20
-ERROR Argument `dict[str, dict[Unknown, Unknown]]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.webhook_service.WebhookService.generate_webhook_response` [bad-argument-type]
-   --> tests/unit_tests/services/trigger/test_webhook_service.py:589:83
-ERROR Argument `dict[str, dict[str, int | str]]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.webhook_service.WebhookService.generate_webhook_response` [bad-argument-type]
-   --> tests/unit_tests/services/trigger/test_webhook_service.py:599:83
-ERROR Argument `dict[str, dict[str, int | str]]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.webhook_service.WebhookService.generate_webhook_response` [bad-argument-type]
-   --> tests/unit_tests/services/trigger/test_webhook_service.py:609:83
-ERROR Argument `dict[str, dict[str, int | str]]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.webhook_service.WebhookService.generate_webhook_response` [bad-argument-type]
-   --> tests/unit_tests/services/trigger/test_webhook_service.py:618:83
-ERROR Argument `dict[str, dict[str, int | str]]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.webhook_service.WebhookService.generate_webhook_response` [bad-argument-type]
-   --> tests/unit_tests/services/trigger/test_webhook_service.py:627:83
-ERROR Argument `dict[str, dict[str, int | str]]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.webhook_service.WebhookService.generate_webhook_response` [bad-argument-type]
-   --> tests/unit_tests/services/trigger/test_webhook_service.py:637:83
-ERROR Argument `dict[str, dict[str, list[dict[str, bool | str]] | str]]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.webhook_service.WebhookService.extract_and_validate_webhook_data` [bad-argument-type]
-   --> tests/unit_tests/services/trigger/test_webhook_service.py:895:38
-ERROR Argument `dict[str, dict[str, str]]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.webhook_service.WebhookService.extract_and_validate_webhook_data` [bad-argument-type]
-   --> tests/unit_tests/services/trigger/test_webhook_service.py:924:42
-ERROR Argument `dict[str, dict[str, str]]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.webhook_service.WebhookService.extract_and_validate_webhook_data` [bad-argument-type]
-   --> tests/unit_tests/services/trigger/test_webhook_service.py:946:42
-ERROR Argument `dict[str, dict[str, list[dict[str, bool | str]] | str]]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.webhook_service.WebhookService.extract_and_validate_webhook_data` [bad-argument-type]
-   --> tests/unit_tests/services/trigger/test_webhook_service.py:966:45
-ERROR Argument `dict[str, dict[str, list[dict[str, bool | str]] | str]]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.webhook_service.WebhookService.extract_and_validate_webhook_data` [bad-argument-type]
-   --> tests/unit_tests/services/trigger/test_webhook_service.py:987:41
-ERROR Argument `dict[str, dict[str, list[dict[str, bool | str]] | str]]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.webhook_service.WebhookService.extract_and_validate_webhook_data` [bad-argument-type]
-    --> tests/unit_tests/services/trigger/test_webhook_service.py:1011:45
-ERROR Argument `dict[str, dict[str, list[dict[str, bool | str]] | str]]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.webhook_service.WebhookService.extract_and_validate_webhook_data` [bad-argument-type]
-    --> tests/unit_tests/services/trigger/test_webhook_service.py:1032:45
-ERROR Argument `dict[str, dict[str, list[dict[str, bool | str]] | str]]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.webhook_service.WebhookService.extract_and_validate_webhook_data` [bad-argument-type]
-    --> tests/unit_tests/services/trigger/test_webhook_service.py:1053:45
-ERROR Argument `dict[str, dict[str, list[dict[str, bool | str]] | str]]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.webhook_service.WebhookService.extract_and_validate_webhook_data` [bad-argument-type]
-    --> tests/unit_tests/services/trigger/test_webhook_service.py:1073:41
-ERROR Argument `dict[str, str | dict[str, str]]` is not assignable to parameter `webhook_data` with type `RawWebhookDataDict` in function `services.trigger.webhook_service.WebhookService._validate_http_metadata` [bad-argument-type]
-    --> tests/unit_tests/services/trigger/test_webhook_service.py:1356:61
-ERROR Argument `dict[str, dict[str, int] | dict[str, str]]` is not assignable to parameter `webhook_data` with type `RawWebhookDataDict` in function `services.trigger.webhook_service.WebhookService.build_workflow_inputs` [bad-argument-type]
-    --> tests/unit_tests/services/trigger/test_webhook_service.py:1368:59
-ERROR Argument `dict[str, dict[str, int | str]]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.webhook_service.WebhookService.generate_webhook_response` [bad-argument-type]
-    --> tests/unit_tests/services/trigger/test_webhook_service.py:1379:69
 ERROR Cannot find module `dify_graph.enums` [missing-import]
   --> tests/unit_tests/services/workflow/test_workflow_converter.py:36:5
 ERROR Cannot find module `dify_graph.model_runtime.entities.llm_entities` [missing-import]

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 84.64% 84.75% +0.10%
Strict coverage 84.30% 84.41% +0.11%
Typed symbols 88,939 89,028 +89
Untyped symbols 16,204 16,090 -114
Modules 4443 4445 +2

Comment thread api/controllers/trigger/webhook.py Fixed
Comment thread api/controllers/trigger/webhook.py Fixed
@codecov

codecov Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.77489% with 38 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.09%. Comparing base (ca9738e) to head (cf0039d).

Files with missing lines Patch % Lines
api/controllers/trigger/webhook_request.py 87.58% 24 Missing and 12 partials ⚠️
api/repositories/trigger/app_repository.py 95.65% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #45912      +/-   ##
==========================================
- Coverage   90.09%   90.09%   -0.01%     
==========================================
  Files        6269     6271       +2     
  Lines      392030   392013      -17     
  Branches    78453    78442      -11     
==========================================
- Hits       353203   353170      -33     
- Misses      32735    32750      +15     
- Partials     6092     6093       +1     
Flag Coverage Δ
api 89.93% <91.77%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hjlarry
hjlarry marked this pull request as ready for review November 9, 2026 09:32
Stream29 and others added 2 commits November 10, 2026 03:10
…ok-runtime

# Conflicts:
#	api/controllers/trigger/webhook.py
#	api/services/trigger/webhook_service.py
#	api/tests/unit_tests/controllers/trigger/test_webhook.py
#	api/tests/unit_tests/services/trigger/test_webhook_service.py

@Stream29 Stream29 left a comment

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.

LGTM

@Stream29
Stream29 added this pull request to the merge queue Nov 10, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 10, 2026
@hjlarry
hjlarry added this pull request to the merge queue Nov 10, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 10, 2026
@hjlarry
hjlarry added this pull request to the merge queue Nov 10, 2026
Merged via the queue into main with commit 9fbd9dc Nov 10, 2026
55 checks passed
@hjlarry
hjlarry deleted the hjlarry/trigger-webhook-runtime branch November 10, 2026 05:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants