Repository navigation
refactor(models): pass session into WorkflowDraftVariable value decoding - #43112
asukaminato0721 merged 8 commits into
Conversation
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-11-12 01:44:19.105652642 +0000
+++ /tmp/pyrefly_pr.txt 2026-11-12 01:43:58.725479404 +0000
@@ -5878,55 +5878,55 @@
ERROR Argument `None` is not assignable to parameter `value` with type `SQLCoreOperations[UploadFile] | UploadFile` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
--> tests/unit_tests/services/test_workflow_draft_variable_service.py:203:41
ERROR Argument `Literal['opendal']` is not assignable to parameter `storage_type` with type `StorageType` in function `models.model.UploadFile.__init__` [bad-argument-type]
- --> tests/unit_tests/services/test_workflow_draft_variable_service.py:235:30
+ --> tests/unit_tests/services/test_workflow_draft_variable_service.py:299:30
ERROR Argument `Literal['account']` is not assignable to parameter `created_by_role` with type `CreatorUserRole` in function `models.model.UploadFile.__init__` [bad-argument-type]
- --> tests/unit_tests/services/test_workflow_draft_variable_service.py:241:33
+ --> tests/unit_tests/services/test_workflow_draft_variable_service.py:305:33
ERROR Argument `Literal['opendal']` is not assignable to parameter `storage_type` with type `StorageType` in function `models.model.UploadFile.__init__` [bad-argument-type]
- --> tests/unit_tests/services/test_workflow_draft_variable_service.py:291:30
+ --> tests/unit_tests/services/test_workflow_draft_variable_service.py:355:30
ERROR Argument `Literal['account']` is not assignable to parameter `created_by_role` with type `CreatorUserRole` in function `models.model.UploadFile.__init__` [bad-argument-type]
- --> tests/unit_tests/services/test_workflow_draft_variable_service.py:297:33
+ --> tests/unit_tests/services/test_workflow_draft_variable_service.py:361:33
ERROR Object of class `Account` has no attribute `tenant_id` [missing-attribute]
- --> tests/unit_tests/services/test_workflow_draft_variable_service.py:740:13
+ --> tests/unit_tests/services/test_workflow_draft_variable_service.py:804:13
ERROR Object of class `Account` has no attribute `tenant_id` [missing-attribute]
- --> tests/unit_tests/services/test_workflow_draft_variable_service.py:775:13
+ --> tests/unit_tests/services/test_workflow_draft_variable_service.py:839:13
ERROR Argument `None` is not assignable to parameter `value` with type `SQLCoreOperations[bool] | bool` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
- --> tests/unit_tests/services/test_workflow_draft_variable_service.py:1168:41
+ --> tests/unit_tests/services/test_workflow_draft_variable_service.py:1232:41
ERROR Argument `Literal['workflow-run']` is not assignable to parameter `triggered_from` with type `SQLCoreOperations[WorkflowNodeExecutionTriggeredFrom] | WorkflowNodeExecutionTriggeredFrom` in function `models.workflow.WorkflowNodeExecutionModel.__init__` [bad-argument-type]
- --> tests/unit_tests/services/test_workflow_draft_variable_service.py:1754:32
+ --> tests/unit_tests/services/test_workflow_draft_variable_service.py:1818:32
ERROR No matching overload found for function `typing.MutableMapping.update` called with arguments: (dict[str, object]) [no-matching-overload]
- --> tests/unit_tests/services/test_workflow_node_execution_trace_service.py:41:18
+ --> tests/unit_tests/services/test_workflow_node_execution_trace_service.py:32:18
ERROR Argument `dict[str, list[dict[str, object]] | str]` is not assignable to parameter `process_data` with type `dict[str, object]` in function `_execution` [bad-argument-type]
- --> tests/unit_tests/services/test_workflow_node_execution_trace_service.py:86:28
+ --> tests/unit_tests/services/test_workflow_node_execution_trace_service.py:77:28
ERROR Argument `dict[str, list[dict[str, object]] | str]` is not assignable to parameter `full_process_data` with type `dict[str, object] | None` in function `_repository` [bad-argument-type]
- --> tests/unit_tests/services/test_workflow_node_execution_trace_service.py:87:30
+ --> tests/unit_tests/services/test_workflow_node_execution_trace_service.py:78:30
ERROR `not in` is not supported between `Literal['__dify_retry_history']` and `None` [not-iterable]
- --> tests/unit_tests/services/test_workflow_node_execution_trace_service.py:96:12
+ --> tests/unit_tests/services/test_workflow_node_execution_trace_service.py:87:12
ERROR Object of class `FunctionType` has no attribute `assert_called_once_with` [missing-attribute]
- --> tests/unit_tests/services/test_workflow_node_execution_trace_service.py:105:5
+ --> tests/unit_tests/services/test_workflow_node_execution_trace_service.py:96:5
ERROR Argument `dict[str, str]` is not assignable to parameter `process_data` with type `dict[str, object]` in function `_execution` [bad-argument-type]
- --> tests/unit_tests/services/test_workflow_node_execution_trace_service.py:110:28
+ --> tests/unit_tests/services/test_workflow_node_execution_trace_service.py:101:28
ERROR Argument `dict[str, str]` is not assignable to parameter `full_process_data` with type `dict[str, object] | None` in function `_repository` [bad-argument-type]
- --> tests/unit_tests/services/test_workflow_node_execution_trace_service.py:112:79
+ --> tests/unit_tests/services/test_workflow_node_execution_trace_service.py:103:79
ERROR Argument `dict[str, list[dict[str, int] | dict[str, object]]]` is not assignable to parameter `process_data` with type `dict[str, object]` in function `_execution` [bad-argument-type]
- --> tests/unit_tests/services/test_workflow_node_execution_trace_service.py:130:21
+ --> tests/unit_tests/services/test_workflow_node_execution_trace_service.py:121:21
ERROR Argument `dict[str, list[dict[str, int] | dict[str, object]]]` is not assignable to parameter `full_process_data` with type `dict[str, object] | None` in function `_repository` [bad-argument-type]
- --> tests/unit_tests/services/test_workflow_node_execution_trace_service.py:130:49
+ --> tests/unit_tests/services/test_workflow_node_execution_trace_service.py:121:49
ERROR Argument `dict[str, list[dict[str, object]]]` is not assignable to parameter `process_data` with type `dict[str, object]` in function `_execution` [bad-argument-type]
- --> tests/unit_tests/services/test_workflow_node_execution_trace_service.py:141:21
+ --> tests/unit_tests/services/test_workflow_node_execution_trace_service.py:132:21
ERROR Argument `dict[str, list[dict[str, object]]]` is not assignable to parameter `full_process_data` with type `dict[str, object] | None` in function `_repository` [bad-argument-type]
- --> tests/unit_tests/services/test_workflow_node_execution_trace_service.py:141:49
+ --> tests/unit_tests/services/test_workflow_node_execution_trace_service.py:132:49
ERROR Argument `dict[str, list[dict[str, object]]]` is not assignable to parameter `process_data` with type `dict[str, object]` in function `_execution` [bad-argument-type]
- --> tests/unit_tests/services/test_workflow_node_execution_trace_service.py:150:28
+ --> tests/unit_tests/services/test_workflow_node_execution_trace_service.py:141:28
ERROR Object of class `FunctionType` has no attribute `side_effect` [missing-attribute]
- --> tests/unit_tests/services/test_workflow_node_execution_trace_service.py:152:5
+ --> tests/unit_tests/services/test_workflow_node_execution_trace_service.py:143:5
ERROR Argument `dict[str, list[dict[str, object]]]` is not assignable to parameter `process_data` with type `dict[str, object]` in function `_execution` [bad-argument-type]
- --> tests/unit_tests/services/test_workflow_node_execution_trace_service.py:162:21
+ --> tests/unit_tests/services/test_workflow_node_execution_trace_service.py:153:21
ERROR Argument `dict[str, list[dict[str, object]]]` is not assignable to parameter `full_process_data` with type `dict[str, object] | None` in function `_repository` [bad-argument-type]
- --> tests/unit_tests/services/test_workflow_node_execution_trace_service.py:162:49
+ --> tests/unit_tests/services/test_workflow_node_execution_trace_service.py:153:49
ERROR Argument `dict[str, list[dict[str, object]]]` is not assignable to parameter `process_data` with type `dict[str, object]` in function `_execution` [bad-argument-type]
- --> tests/unit_tests/services/test_workflow_node_execution_trace_service.py:182:25
+ --> tests/unit_tests/services/test_workflow_node_execution_trace_service.py:173:25
ERROR Argument `dict[str, list[dict[str, object]]]` is not assignable to parameter `full_process_data` with type `dict[str, object] | None` in function `_repository` [bad-argument-type]
- --> tests/unit_tests/services/test_workflow_node_execution_trace_service.py:182:53
+ --> tests/unit_tests/services/test_workflow_node_execution_trace_service.py:173:53
ERROR Missing argument `user_from` in function `core.app.entities.app_invoke_entities.WorkflowAppGenerateEntity.model_construct` [missing-argument]
--> tests/unit_tests/services/test_workflow_persistence.py:327:76
ERROR Argument `SimpleNamespace` is not assignable to parameter `app_config` with type `WorkflowUIBasedAppConfig` in function `core.app.entities.app_invoke_entities.WorkflowAppGenerateEntity.model_construct` [bad-argument-type]
|
Pyrefly Type Coverage
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #43112 +/- ##
==========================================
+ Coverage 90.13% 90.15% +0.01%
==========================================
Files 6305 6307 +2
Lines 394701 394738 +37
Branches 79183 79183
==========================================
+ Hits 355779 355871 +92
+ Misses 32806 32755 -51
+ Partials 6116 6112 -4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Head branch was pushed to by a user without write access
be406c2 to
672e959
Compare
|
Rebased on current main as requested. The explicit session injection is retained, tests follow the consolidated upstream layout, and serialization preserves the current file URL refresh/copy behavior. The first CI run found missing test return annotations and obsolete fixture patches of models.workflow.db; these are fixed in c05590d. Validation: 296 related unit tests passed, including the three suites affected by the CI failures. Ruff formatting/lint passed for all 17 changed Python files; Pyrefly reported 0 diagnostics for the six changed production files and the four strict field/model/handler test files. GitHub CI is rerunning on the updated head. Drafted-by: Codex (GPT-6); reviewed by @keith991001 before posting |
|
Resolved the remaining coverage failure in e998b3e by adding SQLite-backed snippet variable GET/PATCH tests that verify decoded response values and persisted updates. Main CI Pipeline #61569 passed, including unit, controller, integration, style/type and Web E2E checks. After all coverage reports arrived, Codecov patch coverage passed at 91.59% (target 90.13%), and API project coverage passed at 90.01%. Current head has 39 successful checks, 14 skipped, and no failures. Drafted-by: Codex (GPT-6); reviewed by @keith991001 before posting |
Head branch was pushed to by a user without write access
Part of #40372 (claimed in #40372 (comment)). This removes the global
db.sessionlookup from draft-variable value decoding inapi/models/workflow.py.The decoding chain now takes an explicit
Session.WorkflowDraftVariableServiceuses its caller's session, andDraftVarLoaderdecodes variables while the loading session remains open. Offloaded values loaded by worker threads use separate short-lived sessions.Response serialization uses
WorkflowDraftVariableResponseSource, based onSessionResponseSource. The app, RAG pipeline, and snippet controllers pass their active sessions at the response boundary. Value-bearing responses reject bare models to prevent leaking serialized JSON as the value. File URL refresh and the cached-value copy behavior from current main are preserved.Rebased on current main on 2026-11-11, adapting tests to the consolidated model, service, and field test files. Handler tests exercise real services against SQLite. Follow-up c05590d also removes obsolete test patches of the deleted model-level database binding and adds required return annotations. The explicit session injection requested in review is retained.
Current validation: 298 related unit tests passed; Ruff formatting/lint passed for all 18 changed Python files; Pyrefly reported 0 diagnostics for the six changed production files; the no-new-test-doubles guard and
git diff --checkpassed. On c05590d, GitHub Main CI Pipeline #61563 passed, including both unit shards, controllers, integration tests, Python Style and Web E2E. Codecov patch coverage remained at 89.91% against a 90.13% target after all reports arrived. Follow-up e998b3e adds SQLite-backed snippet GET/PATCH tests for decoded response values and persisted updates; its 15-test suite, Ruff and strict Pyrefly check pass locally. GitHub Main CI Pipeline #61569 passed on e998b3e. Final Codecov patch coverage is 91.59% (target 90.13%) and the API project coverage check passed at 90.01%. All 39 current checks passed, with 14 skipped and none failing.Originally assisted by Claude Code; current rebase and test updates assisted by Codex (GPT-6).
Drafted-by: Codex (GPT-6); reviewed by @keith991001 before posting