Repository navigation
refactor(models): pass session into WorkflowRun accessors and drop dead ones - #42034
asukaminato0721 merged 4 commits into
Conversation
Pyrefly Type Coverage
|
9e6d4d8 to
a255b31
Compare
|
Hi @asukaminato0721 — a friendly ping on this one whenever you have a moment. CI is all green and the branch is up to date. Happy to rebase or adjust anything if needed. Thanks for your time! 🙏 |
Head branch was pushed to by a user without write access
|
Hi @asukaminato0721 — just a quick note that both review comments have been addressed in 26c3537 (shared |
…rator Review feedback: the workflow-run endpoints this PR touched obtained their session inline with db.session(). Switch the eight read handlers across workflow_run.py, rag_pipeline_workflow.py and snippet_workflow.py to @with_session(write=False), which injects a request-scoped session and owns its lifecycle. Handler unit tests updated to pass the session explicitly (real sqlite fixture, no Mock sessions).
Head branch was pushed to by a user without write access
26c3537 to
9247d1d
Compare
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-09-17 15:26:09.241332351 +0000
+++ /tmp/pyrefly_pr.txt 2026-09-17 15:26:00.721277335 +0000
@@ -434,6 +434,10 @@
--> providers/vdb/vdb-vikingdb/tests/unit_tests/test_vikingdb_vector.py:76:5
ERROR Object of class `ModuleType` has no attribute `VikingDBService` [missing-attribute]
--> providers/vdb/vdb-vikingdb/tests/unit_tests/test_vikingdb_vector.py:77:5
+ERROR Argument `(self: Self@AdvancedChatAppWorkflowRunListApi, session: Session, req_data: WorkflowRunListQuery, request_context: RequestContext, app_model: App) -> dict[str, Any]` is not assignable to parameter with type `(Self@AdvancedChatAppWorkflowRunListApi, WorkflowRunListQuery, ParamSpec(@_)) -> @_` [bad-argument-type]
+ --> controllers/console/app/workflow_run.py:154:5
+ERROR Argument `(self: Self@WorkflowRunListApi, session: Session, req_data: WorkflowRunListQuery, request_context: RequestContext, app_model: App) -> dict[str, Any]` is not assignable to parameter with type `(Self@WorkflowRunListApi, WorkflowRunListQuery, ParamSpec(@_)) -> @_` [bad-argument-type]
+ --> controllers/console/app/workflow_run.py:219:5
ERROR Object of class `FromClause` has no attribute `metadata` [missing-attribute]
--> tests/helpers/legacy_model_type_migration.py:64:16
ERROR Object of class `FromClause` has no attribute `metadata` [missing-attribute]
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #42034 +/- ##
==========================================
- Coverage 87.40% 87.40% -0.01%
==========================================
Files 5462 5462
Lines 315635 315637 +2
Branches 63612 63612
==========================================
+ Hits 275867 275868 +1
- Misses 34385 34387 +2
+ Partials 5383 5382 -1
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:
|
…lers Pyrefly caught a real wiring bug in the previous commit: with @with_session stacked outside @model_validate, the decorator chain delivered req_data into the session parameter and vice versa on the two list endpoints. model_validate prepends the validated payload directly after self on the callable it wraps, so the session-injecting decorator must sit innermost for the raw signature (self, session, req_data, ...) to line up. The unwrap-based unit tests bypass the decorator chain, which is why they could not catch this.
thx! I fixed CI. plz check again |
Important
workflow.pyaccessors).Summary
Part of #40372, follow-up to #41968 — this finishes
models/workflow.py: nodb.session-backed@propertyremains in the file.WorkflowRun.created_by_account/created_by_end_user(both marked@deprecated) → converted to methods takingsession, matching theWorkflowAppLog/WorkflowNodeExecutionModelpairs in the same file. Their only remaining readers were implicitfrom_attributes=Truereads by the run list / detail response models, now routed through a session-carryingWorkflowRunResponseSource(plus a pagination helper that wraps each run in the page) at the seven console validation sites (app workflow-runs list ×2 / detail, snippets list / detail, rag-pipeline list / detail). Each site reusesdb.session()at the boundary. The advanced-chat list keeps working throughWorkflowWithMessage's attribute passthrough — the source resolves the accessor on the underlying run whilemessage_id/conversation_idkeep proxying.WorkflowRun.message/WorkflowRun.workflow(also@deprecated) → removed: an untruncated sweep across production, serializers, helper-indirecteddump_responsesites, events, and tests found zero readers.Tests
test_workflow_run_accessors.py: both accessors against the realsqlite_sessionfixture (role dispatch + None paths), the detail source resolving through its wrapped session while proxying other attributes, and the pagination helper wrapping every run in a page.test_workflow_run_api.pycontract tests adapted: thedb.sessionmonkeypatch is now a callable (matching the scoped-session contract the controllers rely on), and the two mocked paginations use object-shaped results matching what the repository layer actually returns.tests/unit_testsrun: 18661 passed; the only failures are the same pre-existingtest_check_no_new_getattrenvironment failures that fail identically on a cleanmaincheckout on this machine.Screenshots
N/A (backend-only refactor).
Checklist
make lint && make type-check(backend) andvp staged(frontend) to appease the lint godsFrom Claude Code