refactor(api): type webhook data extraction with RawWebhookDataDict TypedDict#34486
Merged
asukaminato0721 merged 1 commit intolanggenius:mainfrom Apr 3, 2026
Merged
Conversation
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-02 15:45:21.470739938 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-02 15:45:12.709762305 +0000
@@ -14,6 +14,10 @@
--> controllers/console/setup.py:65:2
ERROR Object of class `MissingRouter` has no attribute `get` [missing-attribute]
--> controllers/console/version.py:30:2
+ERROR Argument `dict[str, dict[str, str] | dict[Unknown, Unknown] | str] | RawWebhookDataDict` is not assignable to parameter `webhook_data` with type `dict[str, Any]` in function `services.trigger.webhook_service.WebhookService.trigger_workflow_execution` [bad-argument-type]
+ --> controllers/trigger/webhook.py:56:68
+ERROR Argument `dict[str, dict[str, str] | dict[Unknown, Unknown] | str] | RawWebhookDataDict` is not assignable to parameter `webhook_data` with type `dict[str, Any]` in function `services.trigger.webhook_service.WebhookService.build_workflow_inputs` [bad-argument-type]
+ --> controllers/trigger/webhook.py:86:64
ERROR Class member `EasyUIBasedGenerateTaskPipeline._application_generate_entity` overrides parent class `BasedGenerateTaskPipeline` in an inconsistent manner [bad-override]
--> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:75:5
ERROR `+=` is not supported between `list[PromptMessageContentUnionTypes]` and `str` [unsupported-operation]
@@ -343,6 +347,8 @@
--> services/document_indexing_proxy/duplicate_document_indexing_task_proxy.py:15:5
ERROR `handled_tenant_count` was assigned in the current scope before the nonlocal declaration [unknown-name]
--> services/plugin/plugin_migration.py:81:34
+ERROR Argument `RawWebhookDataDict` is not assignable to parameter `webhook_data` with type `dict[str, Any]` in function `WebhookService._validate_http_metadata` [bad-argument-type]
+ --> services/trigger/webhook_service.py:174:57
ERROR Object of class `dict` has no attribute `encode`
ERROR Object of class `dict` has no attribute `encode`
ERROR Returned type `EndUser | Unknown | None` is not assignable to declared return type `Account | EndUser` [bad-return]
|
a5e596a to
1e81fad
Compare
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-02 16:00:19.015568062 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-02 16:00:09.538546845 +0000
@@ -6658,6 +6658,28 @@
--> tests/unit_tests/services/test_webhook_service.py:515:83
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/test_webhook_service.py:535:83
+ERROR Argument `dict[str, dict[str, 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/test_webhook_service.py:1021:53
+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/test_webhook_service.py:1044:51
+ERROR Argument `dict[str, dict[str, int]]` is not assignable to parameter `webhook_data` with type `RawWebhookDataDict` in function `services.trigger.webhook_service.WebhookService.trigger_workflow_execution` [bad-argument-type]
+ --> tests/unit_tests/services/test_webhook_service.py:1077:64
+ERROR Missing required key `method` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
+ --> tests/unit_tests/services/test_webhook_service.py:1114:68
+ERROR Missing required key `headers` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
+ --> tests/unit_tests/services/test_webhook_service.py:1114:68
+ERROR Missing required key `query_params` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
+ --> tests/unit_tests/services/test_webhook_service.py:1114:68
+ERROR Missing required key `files` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
+ --> tests/unit_tests/services/test_webhook_service.py:1114:68
+ERROR Missing required key `method` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
+ --> tests/unit_tests/services/test_webhook_service.py:1139:68
+ERROR Missing required key `headers` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
+ --> tests/unit_tests/services/test_webhook_service.py:1139:68
+ERROR Missing required key `query_params` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
+ --> tests/unit_tests/services/test_webhook_service.py:1139:68
+ERROR Missing required key `files` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
+ --> tests/unit_tests/services/test_webhook_service.py:1139:68
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/test_webhook_service.py:1290:61
ERROR Missing required key `id` for TypedDict `NodeConfigDict` [bad-typed-dict-key]
|
1e81fad to
86233a3
Compare
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-02 16:32:29.486869419 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-02 16:32:19.929931044 +0000
@@ -6658,6 +6658,28 @@
--> tests/unit_tests/services/test_webhook_service.py:515:83
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/test_webhook_service.py:535:83
+ERROR Argument `dict[str, dict[str, 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/test_webhook_service.py:1021:53
+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/test_webhook_service.py:1044:51
+ERROR Argument `dict[str, dict[str, int]]` is not assignable to parameter `webhook_data` with type `RawWebhookDataDict` in function `services.trigger.webhook_service.WebhookService.trigger_workflow_execution` [bad-argument-type]
+ --> tests/unit_tests/services/test_webhook_service.py:1077:64
+ERROR Missing required key `method` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
+ --> tests/unit_tests/services/test_webhook_service.py:1114:68
+ERROR Missing required key `headers` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
+ --> tests/unit_tests/services/test_webhook_service.py:1114:68
+ERROR Missing required key `query_params` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
+ --> tests/unit_tests/services/test_webhook_service.py:1114:68
+ERROR Missing required key `files` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
+ --> tests/unit_tests/services/test_webhook_service.py:1114:68
+ERROR Missing required key `method` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
+ --> tests/unit_tests/services/test_webhook_service.py:1139:68
+ERROR Missing required key `headers` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
+ --> tests/unit_tests/services/test_webhook_service.py:1139:68
+ERROR Missing required key `query_params` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
+ --> tests/unit_tests/services/test_webhook_service.py:1139:68
+ERROR Missing required key `files` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
+ --> tests/unit_tests/services/test_webhook_service.py:1139:68
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/test_webhook_service.py:1290:61
ERROR Missing required key `id` for TypedDict `NodeConfigDict` [bad-typed-dict-key]
|
asukaminato0721
approved these changes
Apr 3, 2026
HanqingZ
pushed a commit
to HanqingZ/dify
that referenced
this pull request
Apr 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RawWebhookDataDictTypedDict with keysmethod,headers,query_params,body,filesextract_webhook_data,extract_and_validate_webhook_data, and_process_and_validate_dataWhy this change
extract_webhook_dataconstructs a dict with 5 well-documented fixed keys but was typed asdict[str, Any]. The same shape flows through_process_and_validate_dataandextract_and_validate_webhook_data. A TypedDict makes the webhook data contract explicit at every layer.Changes
services/trigger/webhook_service.py: DefineRawWebhookDataDict, update 3 method signaturesTest plan
ruff checkpassesPart of #32863 (
services/trigger/webhook_service.py)