Repository navigation
refactor(models): pass session into WorkflowDraftVariable value decoding - #43112
Open
keith991001 wants to merge 4 commits into
Open
keith991001 wants to merge 4 commits into
keith991001 wants to merge 4 commits into
Conversation
keith991001
requested review from
JohnJyong,
QuantumGhost and
laipz8200
as code owners
September 29, 2026 02:22
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-09-29 03:26:58.203644068 +0000
+++ /tmp/pyrefly_pr.txt 2026-09-29 03:26:49.415447728 +0000
@@ -1885,7 +1885,7 @@
ERROR Unexpected keyword argument `app_id` in function `Handler.get` [unexpected-keyword]
--> tests/unit_tests/controllers/console/app/test_wraps.py:126:37
ERROR Cannot set item in `OrderedDict[str, bool | list[str] | str]` [unsupported-operation]
- --> tests/unit_tests/controllers/console/app/workflow_draft_variables_test.py:136:47
+ --> tests/unit_tests/controllers/console/app/workflow_draft_variables_test.py:144:47
ERROR Object of class `FromClause` has no attribute `create` [missing-attribute]
--> tests/unit_tests/controllers/console/datasets/rag_pipeline/test_rag_pipeline.py:83:9
ERROR Object of class `FromClause` has no attribute `create` [missing-attribute]
@@ -6263,7 +6263,7 @@
ERROR Argument `None` is not assignable to parameter `value` with type `SQLCoreOperations[str] | str` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
--> tests/unit_tests/models/test_tool_models.py:603:47
ERROR Object of class `WorkflowDraftVariable` has no attribute `_WorkflowDraftVariable__value` [missing-attribute]
- --> tests/unit_tests/models/test_workflow.py:445:9
+ --> tests/unit_tests/models/test_workflow.py:447:9
ERROR Argument `None` is not assignable to parameter `graph` with type `str` in function `models.workflow.Workflow.new` [bad-argument-type]
--> tests/unit_tests/models/test_workflow_models.py:938:19
ERROR Class member `TestAliyunOss.setup_method` overrides a member in a parent class but is missing an `@override` decorator [missing-override-decorator]
@@ -6799,13 +6799,13 @@
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/workflow/test_draft_var_loader_simple.py:153:37
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/workflow/test_draft_var_loader_simple.py:178:26
+ --> tests/unit_tests/services/workflow/test_draft_var_loader_simple.py:242:26
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/workflow/test_draft_var_loader_simple.py:184:29
+ --> tests/unit_tests/services/workflow/test_draft_var_loader_simple.py:248:29
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/workflow/test_draft_var_loader_simple.py:230:26
+ --> tests/unit_tests/services/workflow/test_draft_var_loader_simple.py:294:26
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/workflow/test_draft_var_loader_simple.py:236:29
+ --> tests/unit_tests/services/workflow/test_draft_var_loader_simple.py:300:29
ERROR Object of class `Iterator` has no attribute `close` [missing-attribute]
--> tests/unit_tests/services/workflow/test_inspector_events.py:181:9
ERROR Object of class `Iterator` has no attribute `close` [missing-attribute]
|
Contributor
Pyrefly Type Coverage
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #43112 +/- ##
=======================================
Coverage 88.33% 88.34%
=======================================
Files 5133 5133
Lines 324423 324427 +4
Branches 65349 65349
=======================================
+ Hits 286593 286626 +33
+ Misses 32445 32421 -24
+ Partials 5385 5380 -5
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:
|
| @@ -323,8 +327,9 @@ class VariableApi(Resource): | |||
| @_api_prerequisite | |||
| @rbac_permission_required(RBACCheck(RBACPermission.APP_VIEW_LAYOUT, PlainApp())) | |||
| def get(self, current_user: Account, app_model: App, variable_id: UUID): | |||
Contributor
There was a problem hiding this comment.
inject session here
Contributor
Author
There was a problem hiding this comment.
THX for ur comment! Done in 6b9af5e
asukaminato0721
requested changes
Sep 29, 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.
Part of #40372 (claimed in #40372 (comment)). This removes the last raw
db.sessionread inapi/models/:_resolve_workflow_app_tenant_id.Summary
WorkflowDraftVariable's value decoding chain (get_value→_loads_value→build_segment_from_serialized_value→_rebuild_file_types→_resolve_workflow_app_tenant_id) resolved the app's tenant through the globaldb.session. The whole chain now takes an explicitsession: Session.Call sites
WorkflowDraftVariableService: passes its own_session(4 sites).DraftVarLoader.load_variables: restructured — the decode loop moves inside the session block that loaded the variables (previously it decoded after that session closed, which only worked because of the global-session fallback), and the two passes overdraft_varsmerge into one._load_offloaded_variableruns on a thread pool, so each call opens its own short-lived session instead of sharing one.fields/workflow_draft_variable_fields.py(_serialize_var_valueviadump_response) getsWorkflowDraftVariableResponseSourceon the sharedSessionResponseSourcebase from refactor(models): pass session into WorkflowRun accessors and drop dead ones #42034; the three draft-variable controllers wrap at theirdump_responseboundaries with the session each handler already holds (@with_sessionin the snippet controller, the handler's existing session otherwise).WorkflowDraftVariablehanded to the value-carrying response now raises aTypeErrorinstead of silently falling throughfrom_attributesand exposing the raw serialized JSON string as the value.get_value()'s caching contract is unchanged: the first call decodes with the caller's session and later calls hit the cache.Verified:
ruffclean;pyreflyreports zero errors for every symbol in the chain repo-wide; 11,651 unit tests pass locally (controllers + models + services + fields), including the previously-missedworkflow_draft_variables_test.pyserialization tests, which are updated to use the response source with thesqlite_sessionfixture.From Claude Code