refactor(api): use sessionmaker in plugin & trigger services#34764
Merged
asukaminato0721 merged 2 commits intolanggenius:mainfrom Apr 8, 2026
Merged
Conversation
81ed08e to
d5e8005
Compare
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-08 19:01:53.806132434 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-08 19:01:46.304025634 +0000
@@ -6679,29 +6679,29 @@
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
+ --> tests/unit_tests/services/test_webhook_service.py:1024: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
+ --> tests/unit_tests/services/test_webhook_service.py:1047: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
+ --> tests/unit_tests/services/test_webhook_service.py:1080:64
ERROR Missing required key `method` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
- --> tests/unit_tests/services/test_webhook_service.py:1114:68
+ --> tests/unit_tests/services/test_webhook_service.py:1117:68
ERROR Missing required key `headers` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
- --> tests/unit_tests/services/test_webhook_service.py:1114:68
+ --> tests/unit_tests/services/test_webhook_service.py:1117:68
ERROR Missing required key `query_params` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
- --> tests/unit_tests/services/test_webhook_service.py:1114:68
+ --> tests/unit_tests/services/test_webhook_service.py:1117:68
ERROR Missing required key `files` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
- --> tests/unit_tests/services/test_webhook_service.py:1114:68
+ --> tests/unit_tests/services/test_webhook_service.py:1117:68
ERROR Missing required key `method` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
- --> tests/unit_tests/services/test_webhook_service.py:1139:68
+ --> tests/unit_tests/services/test_webhook_service.py:1142:68
ERROR Missing required key `headers` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
- --> tests/unit_tests/services/test_webhook_service.py:1139:68
+ --> tests/unit_tests/services/test_webhook_service.py:1142:68
ERROR Missing required key `query_params` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
- --> tests/unit_tests/services/test_webhook_service.py:1139:68
+ --> tests/unit_tests/services/test_webhook_service.py:1142:68
ERROR Missing required key `files` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
- --> tests/unit_tests/services/test_webhook_service.py:1139:68
+ --> tests/unit_tests/services/test_webhook_service.py:1142: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
+ --> tests/unit_tests/services/test_webhook_service.py:1292:61
ERROR Missing required key `id` for TypedDict `NodeConfigDict` [bad-typed-dict-key]
--> tests/unit_tests/services/test_workflow_service.py:2682:71
ERROR Missing required key `data` for TypedDict `NodeConfigDict` [bad-typed-dict-key]
|
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-08 19:03:37.301172772 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-08 19:03:27.428259767 +0000
@@ -6679,29 +6679,29 @@
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
+ --> tests/unit_tests/services/test_webhook_service.py:1024: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
+ --> tests/unit_tests/services/test_webhook_service.py:1047: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
+ --> tests/unit_tests/services/test_webhook_service.py:1080:64
ERROR Missing required key `method` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
- --> tests/unit_tests/services/test_webhook_service.py:1114:68
+ --> tests/unit_tests/services/test_webhook_service.py:1117:68
ERROR Missing required key `headers` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
- --> tests/unit_tests/services/test_webhook_service.py:1114:68
+ --> tests/unit_tests/services/test_webhook_service.py:1117:68
ERROR Missing required key `query_params` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
- --> tests/unit_tests/services/test_webhook_service.py:1114:68
+ --> tests/unit_tests/services/test_webhook_service.py:1117:68
ERROR Missing required key `files` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
- --> tests/unit_tests/services/test_webhook_service.py:1114:68
+ --> tests/unit_tests/services/test_webhook_service.py:1117:68
ERROR Missing required key `method` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
- --> tests/unit_tests/services/test_webhook_service.py:1139:68
+ --> tests/unit_tests/services/test_webhook_service.py:1142:68
ERROR Missing required key `headers` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
- --> tests/unit_tests/services/test_webhook_service.py:1139:68
+ --> tests/unit_tests/services/test_webhook_service.py:1142:68
ERROR Missing required key `query_params` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
- --> tests/unit_tests/services/test_webhook_service.py:1139:68
+ --> tests/unit_tests/services/test_webhook_service.py:1142:68
ERROR Missing required key `files` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
- --> tests/unit_tests/services/test_webhook_service.py:1139:68
+ --> tests/unit_tests/services/test_webhook_service.py:1142: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
+ --> tests/unit_tests/services/test_webhook_service.py:1292:61
ERROR Missing required key `id` for TypedDict `NodeConfigDict` [bad-typed-dict-key]
--> tests/unit_tests/services/test_workflow_service.py:2682:71
ERROR Missing required key `data` for TypedDict `NodeConfigDict` [bad-typed-dict-key]
|
d5e8005 to
9c3b873
Compare
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-08 19:35:02.566911997 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-08 19:34:53.879865361 +0000
@@ -6679,29 +6679,29 @@
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
+ --> tests/unit_tests/services/test_webhook_service.py:1024: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
+ --> tests/unit_tests/services/test_webhook_service.py:1047: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
+ --> tests/unit_tests/services/test_webhook_service.py:1080:64
ERROR Missing required key `method` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
- --> tests/unit_tests/services/test_webhook_service.py:1114:68
+ --> tests/unit_tests/services/test_webhook_service.py:1117:68
ERROR Missing required key `headers` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
- --> tests/unit_tests/services/test_webhook_service.py:1114:68
+ --> tests/unit_tests/services/test_webhook_service.py:1117:68
ERROR Missing required key `query_params` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
- --> tests/unit_tests/services/test_webhook_service.py:1114:68
+ --> tests/unit_tests/services/test_webhook_service.py:1117:68
ERROR Missing required key `files` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
- --> tests/unit_tests/services/test_webhook_service.py:1114:68
+ --> tests/unit_tests/services/test_webhook_service.py:1117:68
ERROR Missing required key `method` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
- --> tests/unit_tests/services/test_webhook_service.py:1139:68
+ --> tests/unit_tests/services/test_webhook_service.py:1142:68
ERROR Missing required key `headers` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
- --> tests/unit_tests/services/test_webhook_service.py:1139:68
+ --> tests/unit_tests/services/test_webhook_service.py:1142:68
ERROR Missing required key `query_params` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
- --> tests/unit_tests/services/test_webhook_service.py:1139:68
+ --> tests/unit_tests/services/test_webhook_service.py:1142:68
ERROR Missing required key `files` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
- --> tests/unit_tests/services/test_webhook_service.py:1139:68
+ --> tests/unit_tests/services/test_webhook_service.py:1142: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
+ --> tests/unit_tests/services/test_webhook_service.py:1292:61
ERROR Missing required key `id` for TypedDict `NodeConfigDict` [bad-typed-dict-key]
--> tests/unit_tests/services/test_workflow_service.py:2682:71
ERROR Missing required key `data` for TypedDict `NodeConfigDict` [bad-typed-dict-key]
|
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-08 19:53:23.818411792 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-08 19:53:14.235520364 +0000
@@ -6679,29 +6679,29 @@
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
+ --> tests/unit_tests/services/test_webhook_service.py:1036: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
+ --> tests/unit_tests/services/test_webhook_service.py:1059: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
+ --> tests/unit_tests/services/test_webhook_service.py:1092:64
ERROR Missing required key `method` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
- --> tests/unit_tests/services/test_webhook_service.py:1114:68
+ --> tests/unit_tests/services/test_webhook_service.py:1129:68
ERROR Missing required key `headers` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
- --> tests/unit_tests/services/test_webhook_service.py:1114:68
+ --> tests/unit_tests/services/test_webhook_service.py:1129:68
ERROR Missing required key `query_params` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
- --> tests/unit_tests/services/test_webhook_service.py:1114:68
+ --> tests/unit_tests/services/test_webhook_service.py:1129:68
ERROR Missing required key `files` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
- --> tests/unit_tests/services/test_webhook_service.py:1114:68
+ --> tests/unit_tests/services/test_webhook_service.py:1129:68
ERROR Missing required key `method` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
- --> tests/unit_tests/services/test_webhook_service.py:1139:68
+ --> tests/unit_tests/services/test_webhook_service.py:1154:68
ERROR Missing required key `headers` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
- --> tests/unit_tests/services/test_webhook_service.py:1139:68
+ --> tests/unit_tests/services/test_webhook_service.py:1154:68
ERROR Missing required key `query_params` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
- --> tests/unit_tests/services/test_webhook_service.py:1139:68
+ --> tests/unit_tests/services/test_webhook_service.py:1154:68
ERROR Missing required key `files` for TypedDict `RawWebhookDataDict` [bad-typed-dict-key]
- --> tests/unit_tests/services/test_webhook_service.py:1139:68
+ --> tests/unit_tests/services/test_webhook_service.py:1154: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
+ --> tests/unit_tests/services/test_webhook_service.py:1304:61
ERROR Missing required key `id` for TypedDict `NodeConfigDict` [bad-typed-dict-key]
--> tests/unit_tests/services/test_workflow_service.py:2682:71
ERROR Missing required key `data` for TypedDict `NodeConfigDict` [bad-typed-dict-key]
|
asukaminato0721
approved these changes
Apr 8, 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
with Session(db.engine)+session.commit()withsessionmaker(bind=db.engine).begin()context manager for automatic transaction management in plugin and trigger services
SessiontosessionmakerpatternFiles changed:
api/services/plugin/plugin_permission_service.pyapi/services/plugin/plugin_auto_upgrade_service.pyapi/services/trigger/app_trigger_service.pyapi/services/trigger/trigger_service.pyapi/services/trigger/webhook_service.pyPart of #24245
Test plan
ruff checkpassesruff format --checkpasses