Skip to content

fix(api): scope nested resource lookups by owner refs#38177

Open
WH-2099 wants to merge 2 commits into
mainfrom
fix/resource-ref-ownership-bindings
Open

fix(api): scope nested resource lookups by owner refs#38177
WH-2099 wants to merge 2 commits into
mainfrom
fix/resource-ref-ownership-bindings

Conversation

@WH-2099

@WH-2099 WH-2099 commented Jun 29, 2026

Copy link
Copy Markdown
Member

Summary

Refs #37983.
Refs #37985.

This PR tightens nested resource ownership checks by carrying trusted owner context through service lookups instead of resolving inner ids by themselves.

  • Add typed NamedTuple refs for dataset, app, and workflow ownership chains.
  • Bind dataset segment, child chunk, document batch delete, TTS message lookup, annotation mutation, App MCP server update, tag update/delete, workflow version mutation, instruction generation, and RAG pipeline document error updates to their outer resource context.
  • Add focused tests that assert the generated SQLAlchemy statements include the owner columns such as tenant, app, dataset, document, pipeline, or workflow owner ids.

Why

Several routes authenticate or resolve an outer resource first, then pass a nested id into lower-level service logic.
The lower layer could then read or mutate by the nested id without preserving the route's full ownership chain.

This makes the trusted boundary explicit: after the outer resource is resolved, internal code uses typed refs or scoped queries that include the relevant parent ids.

Validation

  • uv run --project api ruff check ...
  • git diff --check
  • env DEBUG=false HTTP_PROXY= HTTPS_PROXY= http_proxy= https_proxy= ALL_PROXY= all_proxy= NO_PROXY= no_proxy= uv run --project api pytest -o addopts='' ...

Result: 788 passed, 2 warnings.

@WH-2099 WH-2099 self-assigned this Jun 29, 2026
@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-06-29 20:07:50.760387575 +0000
+++ /tmp/pyrefly_pr.txt	2026-06-29 20:07:42.067344281 +0000
@@ -460,6 +460,12 @@
    --> providers/vdb/vdb-weaviate/tests/unit_tests/test_weaviate_vector.py:891:42
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `dify_vdb_weaviate.weaviate_vector.WeaviateVectorFactory.init_vector` [bad-argument-type]
    --> providers/vdb/vdb-weaviate/tests/unit_tests/test_weaviate_vector.py:920:42
+ERROR Class member `AppRef.__repr__` overrides a member in a parent class but is missing an `@override` decorator [missing-override-decorator]
+  --> services/app_ref_service.py:26:9
+ERROR Class member `DatasetRef.__repr__` overrides a member in a parent class but is missing an `@override` decorator [missing-override-decorator]
+  --> services/dataset_ref_service.py:32:9
+ERROR Class member `WorkflowOwnerRef.__repr__` overrides a member in a parent class but is missing an `@override` decorator [missing-override-decorator]
+  --> services/workflow_ref_service.py:27:9
 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]
@@ -6765,126 +6771,128 @@
 ERROR Class member `DummyRetrieval.get_type` overrides a member in a parent class but is missing an `@override` decorator [missing-override-decorator]
   --> tests/unit_tests/services/rag_pipeline/pipeline_template/test_pipeline_template_base.py:11:9
 ERROR Argument `SimpleNamespace` is not assignable to parameter `session` with type `Session` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.get_all_published_workflow` [bad-argument-type]
-   --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:182:17
+   --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:183:17
 ERROR Argument `SimpleNamespace` is not assignable to parameter `session` with type `Session` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.get_all_published_workflow` [bad-argument-type]
-   --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:200:17
+   --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:201:17
 ERROR Argument `list[str]` is not assignable to parameter `environment_variables` with type `Sequence[VariableBase]` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.sync_draft_workflow` [bad-argument-type]
-   --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:292:31
+   --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:293:31
 ERROR Argument `list[str]` is not assignable to parameter `conversation_variables` with type `Sequence[VariableBase]` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.sync_draft_workflow` [bad-argument-type]
-   --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:293:32
+   --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:294:32
 ERROR Object of class `NoneType` has no attribute `marked_name` [missing-attribute]
-   --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:349:12
-ERROR Object of class `NoneType` has no attribute `marked_comment` [missing-attribute]
    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:350:12
+ERROR Object of class `NoneType` has no attribute `marked_comment` [missing-attribute]
+   --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:351:12
 ERROR Object of class `NoneType` has no attribute `disallowed`
 ERROR Object of class `NoneType` has no attribute `updated_by` [missing-attribute]
-   --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:352:12
+   --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:353:12
+ERROR Argument `SimpleNamespace` is not assignable to parameter `pipeline` with type `Pipeline` in function `services.workflow_ref_service.WorkflowRefService.create_pipeline_workflow_ref` [bad-argument-type]
+   --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:380:68
 ERROR Argument `SimpleNamespace` is not assignable to parameter `pipeline` with type `Pipeline` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.run_datasource_workflow_node` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1085:22
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1118:22
 ERROR Argument `SimpleNamespace` is not assignable to parameter `account` with type `Account` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.run_datasource_workflow_node` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1088:21
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1121:21
 ERROR Argument `SimpleNamespace` is not assignable to parameter `pipeline` with type `Pipeline` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.run_datasource_workflow_node` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1132:22
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1165:22
 ERROR Argument `SimpleNamespace` is not assignable to parameter `account` with type `Account` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.run_datasource_workflow_node` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1135:21
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1168:21
 ERROR Argument `SimpleNamespace` is not assignable to parameter `pipeline` with type `Pipeline` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.run_datasource_workflow_node` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1180:22
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1213:22
 ERROR Argument `SimpleNamespace` is not assignable to parameter `account` with type `Account` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.run_datasource_workflow_node` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1183:21
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1216:21
 ERROR Argument `() -> tuple[SimpleNamespace, Generator[NodeRunFailedEvent, Unknown]]` is not assignable to parameter `getter` with type `() -> tuple[Node[Unknown], Generator[GraphNodeEventBase]]` in function `services.rag_pipeline.rag_pipeline.RagPipelineService._handle_node_run_result` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1229:16
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1262:16
 ERROR Argument `SimpleNamespace` is not assignable to parameter `pipeline` with type `Pipeline` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.get_first_step_parameters` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1247:56
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1280:56
 ERROR Argument `SimpleNamespace` is not assignable to parameter `pipeline` with type `Pipeline` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.get_second_step_parameters` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1275:62
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1308:62
 ERROR Argument `SimpleNamespace` is not assignable to parameter `pipeline` with type `Pipeline` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.set_datasource_variables` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1372:55
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1405:55
 ERROR Argument `SimpleNamespace` is not assignable to parameter `current_user` with type `Account` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.set_datasource_variables` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1372:88
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1405:88
 ERROR Argument `SimpleNamespace` is not assignable to parameter `pipeline` with type `Pipeline` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.run_datasource_workflow_node` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1410:22
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1443:22
 ERROR Argument `SimpleNamespace` is not assignable to parameter `account` with type `Account` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.run_datasource_workflow_node` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1413:21
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1446:21
 ERROR Argument `SimpleNamespace` is not assignable to parameter `pipeline` with type `Pipeline` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.run_datasource_workflow_node` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1463:22
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1496:22
 ERROR Argument `SimpleNamespace` is not assignable to parameter `account` with type `Account` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.run_datasource_workflow_node` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1466:21
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1499:21
 ERROR Argument `SimpleNamespace` is not assignable to parameter `pipeline` with type `Pipeline` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.run_datasource_node_preview` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1518:22
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1551:22
 ERROR Argument `SimpleNamespace` is not assignable to parameter `account` with type `Account` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.run_datasource_node_preview` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1521:21
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1554:21
 ERROR Argument `SimpleNamespace` is not assignable to parameter `pipeline` with type `Pipeline` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.get_first_step_parameters` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1536:61
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1569:61
 ERROR Argument `SimpleNamespace` is not assignable to parameter `pipeline` with type `Pipeline` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.get_second_step_parameters` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1567:62
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1600:62
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.retry_error_document` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1579:13
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1612:13
 ERROR Argument `SimpleNamespace` is not assignable to parameter `document` with type `Document` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.retry_error_document` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1579:32
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1612:32
 ERROR Argument `SimpleNamespace` is not assignable to parameter `user` with type `Account | EndUser` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.retry_error_document` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1579:61
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1612:61
 ERROR Argument `() -> tuple[SimpleNamespace, Generator[object, Unknown]]` is not assignable to parameter `getter` with type `() -> tuple[Node[Unknown], Generator[GraphNodeEventBase]]` in function `services.rag_pipeline.rag_pipeline.RagPipelineService._handle_node_run_result` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1611:20
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1644:20
 ERROR Argument `() -> tuple[SimpleNamespace, Generator[NodeRunFailedEvent, Unknown]]` is not assignable to parameter `getter` with type `() -> tuple[Node[Unknown], Generator[GraphNodeEventBase]]` in function `services.rag_pipeline.rag_pipeline.RagPipelineService._handle_node_run_result` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1668:16
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1704:16
 ERROR Argument `SimpleNamespace` is not assignable to parameter `pipeline` with type `Pipeline` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.run_datasource_node_preview` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1710:22
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1759:22
 ERROR Argument `SimpleNamespace` is not assignable to parameter `account` with type `Account` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.run_datasource_node_preview` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1713:21
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1762:21
 ERROR Argument `SimpleNamespace` is not assignable to parameter `session` with type `Session` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.get_all_published_workflow` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1807:17
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1856:17
 ERROR Argument `SimpleNamespace` is not assignable to parameter `pipeline` with type `Pipeline` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.publish_workflow` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1838:18
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1887:18
 ERROR Argument `SimpleNamespace` is not assignable to parameter `account` with type `Account` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.publish_workflow` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1839:17
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1888:17
 ERROR Argument `SimpleNamespace` is not assignable to parameter `pipeline` with type `Pipeline` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.run_datasource_workflow_node` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1900:22
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1949:22
 ERROR Argument `SimpleNamespace` is not assignable to parameter `account` with type `Account` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.run_datasource_workflow_node` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1903:21
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1952:21
 ERROR Argument `SimpleNamespace` is not assignable to parameter `pipeline` with type `Pipeline` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.run_datasource_workflow_node` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1948:22
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1997:22
 ERROR Argument `SimpleNamespace` is not assignable to parameter `account` with type `Account` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.run_datasource_workflow_node` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1951:21
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2000:21
 ERROR Argument `SimpleNamespace` is not assignable to parameter `pipeline` with type `Pipeline` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.run_datasource_node_preview` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:1997:18
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2046:18
 ERROR Argument `SimpleNamespace` is not assignable to parameter `account` with type `Account` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.run_datasource_node_preview` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2000:17
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2049:17
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.retry_error_document` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2076:13
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2125:13
 ERROR Argument `SimpleNamespace` is not assignable to parameter `document` with type `Document` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.retry_error_document` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2076:32
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2125:32
 ERROR Argument `SimpleNamespace` is not assignable to parameter `user` with type `Account | EndUser` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.retry_error_document` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2076:61
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2125:61
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.retry_error_document` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2091:13
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2140:13
 ERROR Argument `SimpleNamespace` is not assignable to parameter `document` with type `Document` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.retry_error_document` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2091:32
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2140:32
 ERROR Argument `SimpleNamespace` is not assignable to parameter `user` with type `Account | EndUser` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.retry_error_document` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2091:61
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2140:61
 ERROR Argument `SimpleNamespace` is not assignable to parameter `pipeline` with type `Pipeline` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.publish_workflow` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2131:73
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2180:73
 ERROR Argument `SimpleNamespace` is not assignable to parameter `account` with type `Account` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.publish_workflow` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2131:91
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2180:91
 ERROR Argument `SimpleNamespace` is not assignable to parameter `pipeline` with type `Pipeline` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.run_datasource_node_preview` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2141:22
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2190:22
 ERROR Argument `SimpleNamespace` is not assignable to parameter `account` with type `Account` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.run_datasource_node_preview` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2144:21
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2193:21
 ERROR Argument `SimpleNamespace` is not assignable to parameter `pipeline` with type `Pipeline` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.run_datasource_node_preview` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2159:22
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2208:22
 ERROR Argument `SimpleNamespace` is not assignable to parameter `account` with type `Account` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.run_datasource_node_preview` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2162:21
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2211:21
 ERROR Argument `SimpleNamespace` is not assignable to parameter `pipeline` with type `Pipeline` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.run_datasource_node_preview` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2206:18
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2255:18
 ERROR Argument `SimpleNamespace` is not assignable to parameter `account` with type `Account` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.run_datasource_node_preview` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2209:17
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2258:17
 ERROR Argument `SimpleNamespace` is not assignable to parameter `pipeline` with type `Pipeline` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.run_datasource_node_preview` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2247:18
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2296:18
 ERROR Argument `SimpleNamespace` is not assignable to parameter `account` with type `Account` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.run_datasource_node_preview` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2250:17
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2299:17
 ERROR Argument `SimpleNamespace` is not assignable to parameter `pipeline` with type `Pipeline` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.set_datasource_variables` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2264:13
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2313:13
 ERROR Argument `SimpleNamespace` is not assignable to parameter `current_user` with type `Account` in function `services.rag_pipeline.rag_pipeline.RagPipelineService.set_datasource_variables` [bad-argument-type]
-    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2266:13
+    --> tests/unit_tests/services/rag_pipeline/test_rag_pipeline_service.py:2315:13
 ERROR Argument `dict[str, int]` is not assignable to parameter `manifest` with type `ArchiveManifest` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._get_schema_version` [bad-argument-type]
    --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:342:41
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
@@ -6924,11 +6932,11 @@
 ERROR Argument `Literal['created_at']` is not assignable to parameter `k` with type `Never` in function `_typeshed._type_checker_internals.TypedDictFallback.pop` [bad-argument-type]
    --> tests/unit_tests/services/test_agent_drive_service.py:755:32
 ERROR Argument `dict[str, str]` is not assignable to parameter `args` with type `InsertAnnotationArgs` in function `services.annotation_service.AppAnnotationService.insert_app_annotation_directly` [bad-argument-type]
-   --> tests/unit_tests/services/test_annotation_service.py:492:69
+   --> tests/unit_tests/services/test_annotation_service.py:502:69
 ERROR TypedDict `AnnotationSettingDisabledDict` does not have key `embedding_model` [bad-typed-dict-key]
-    --> tests/unit_tests/services/test_annotation_service.py:1221:59
+    --> tests/unit_tests/services/test_annotation_service.py:1237:59
 ERROR TypedDict `AnnotationSettingDisabledDict` does not have key `embedding_model` [bad-typed-dict-key]
-    --> tests/unit_tests/services/test_annotation_service.py:1258:27
+    --> tests/unit_tests/services/test_annotation_service.py:1274:27
 ERROR Class member `_TrackingRateLimit.exit` overrides a member in a parent class but is missing an `@override` decorator [missing-override-decorator]
    --> tests/unit_tests/services/test_app_generate_service.py:532:17
 ERROR Argument `_FakeStreams` is not assignable to parameter `redis_client` with type `Redis[Unknown] | RedisCluster[Unknown]` in function `libs.broadcast_channel.redis.streams_channel.StreamsBroadcastChannel.__init__` [bad-argument-type]
@@ -7016,75 +7024,75 @@
 ERROR Object of class `FakeAccount` has no attribute `current_tenant_id` [missing-attribute]
   --> tests/unit_tests/services/test_dataset_service_document.py:92:9
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `services.dataset_service.DocumentService.update_document_with_dataset_id` [bad-argument-type]
-   --> tests/unit_tests/services/test_dataset_service_document.py:376:65
+   --> tests/unit_tests/services/test_dataset_service_document.py:403:65
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `services.dataset_service.DocumentService.update_document_with_dataset_id` [bad-argument-type]
-   --> tests/unit_tests/services/test_dataset_service_document.py:399:65
+   --> tests/unit_tests/services/test_dataset_service_document.py:426:65
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `services.dataset_service.DocumentService.update_document_with_dataset_id` [bad-argument-type]
-   --> tests/unit_tests/services/test_dataset_service_document.py:436:70
+   --> tests/unit_tests/services/test_dataset_service_document.py:463:70
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `services.dataset_service.DocumentService.update_document_with_dataset_id` [bad-argument-type]
-   --> tests/unit_tests/services/test_dataset_service_document.py:484:65
+   --> tests/unit_tests/services/test_dataset_service_document.py:511:65
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `services.dataset_service.DocumentService.update_document_with_dataset_id` [bad-argument-type]
-   --> tests/unit_tests/services/test_dataset_service_document.py:513:70
+   --> tests/unit_tests/services/test_dataset_service_document.py:540:70
 ERROR Argument `SimpleNamespace` is not assignable to parameter `knowledge_config` with type `KnowledgeConfig` in function `services.dataset_service.DocumentService.document_create_args_validate` [bad-argument-type]
-   --> tests/unit_tests/services/test_dataset_service_document.py:534:59
+   --> tests/unit_tests/services/test_dataset_service_document.py:561:59
 ERROR Argument `SimpleNamespace` is not assignable to parameter `knowledge_config` with type `KnowledgeConfig` in function `services.dataset_service.DocumentService.document_create_args_validate` [bad-argument-type]
-   --> tests/unit_tests/services/test_dataset_service_document.py:543:59
+   --> tests/unit_tests/services/test_dataset_service_document.py:570:59
 ERROR Argument `SimpleNamespace` is not assignable to parameter `knowledge_config` with type `KnowledgeConfig` in function `services.dataset_service.DocumentService.data_source_args_validate` [bad-argument-type]
-   --> tests/unit_tests/services/test_dataset_service_document.py:561:55
+   --> tests/unit_tests/services/test_dataset_service_document.py:588:55
 ERROR Argument `SimpleNamespace` is not assignable to parameter `knowledge_config` with type `KnowledgeConfig` in function `services.dataset_service.DocumentService.data_source_args_validate` [bad-argument-type]
-   --> tests/unit_tests/services/test_dataset_service_document.py:582:55
+   --> tests/unit_tests/services/test_dataset_service_document.py:609:55
 ERROR Argument `list[PreProcessingRule] | None` is not assignable to parameter `obj` with type `Sized` in function `len` [bad-argument-type]
-   --> tests/unit_tests/services/test_dataset_service_document.py:633:20
+   --> tests/unit_tests/services/test_dataset_service_document.py:660:20
 ERROR `None` is not subscriptable [unsupported-operation]
-   --> tests/unit_tests/services/test_dataset_service_document.py:634:16
+   --> tests/unit_tests/services/test_dataset_service_document.py:661:16
 ERROR Argument `SimpleNamespace` is not assignable to parameter `knowledge_config` with type `KnowledgeConfig` in function `services.dataset_service.DocumentService.save_document_with_dataset_id` [bad-argument-type]
-   --> tests/unit_tests/services/test_dataset_service_document.py:765:72
+   --> tests/unit_tests/services/test_dataset_service_document.py:792:72
 ERROR `SimpleNamespace` is not assignable to attribute `process_rule` with type `ProcessRule | None` [bad-assignment]
-   --> tests/unit_tests/services/test_dataset_service_document.py:770:41
+   --> tests/unit_tests/services/test_dataset_service_document.py:797:41
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset_process_rule` with type `DatasetProcessRule | None` in function `services.dataset_service.DocumentService.save_document_with_dataset_id` [bad-argument-type]
-   --> tests/unit_tests/services/test_dataset_service_document.py:809:38
+   --> tests/unit_tests/services/test_dataset_service_document.py:836:38
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset_process_rule` with type `DatasetProcessRule | None` in function `services.dataset_service.DocumentService.save_document_with_dataset_id` [bad-argument-type]
-   --> tests/unit_tests/services/test_dataset_service_document.py:889:38
+   --> tests/unit_tests/services/test_dataset_service_document.py:916:38
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset_process_rule` with type `DatasetProcessRule | None` in function `services.dataset_service.DocumentService.save_document_with_dataset_id` [bad-argument-type]
-   --> tests/unit_tests/services/test_dataset_service_document.py:940:38
+   --> tests/unit_tests/services/test_dataset_service_document.py:967:38
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `services.dataset_service.DocumentService.update_document_with_dataset_id` [bad-argument-type]
-    --> tests/unit_tests/services/test_dataset_service_document.py:1094:70
+    --> tests/unit_tests/services/test_dataset_service_document.py:1121:70
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `services.dataset_service.DocumentService.update_document_with_dataset_id` [bad-argument-type]
-    --> tests/unit_tests/services/test_dataset_service_document.py:1121:65
+    --> tests/unit_tests/services/test_dataset_service_document.py:1148:65
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `services.dataset_service.DocumentService.update_document_with_dataset_id` [bad-argument-type]
-    --> tests/unit_tests/services/test_dataset_service_document.py:1144:65
+    --> tests/unit_tests/services/test_dataset_service_document.py:1171:65
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `services.dataset_service.DocumentService.update_document_with_dataset_id` [bad-argument-type]
-    --> tests/unit_tests/services/test_dataset_service_document.py:1159:65
+    --> tests/unit_tests/services/test_dataset_service_document.py:1186:65
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `services.dataset_service.DocumentService.update_document_with_dataset_id` [bad-argument-type]
-    --> tests/unit_tests/services/test_dataset_service_document.py:1194:70
+    --> tests/unit_tests/services/test_dataset_service_document.py:1221:70
 ERROR Object of class `NoneType` has no attribute `rules` [missing-attribute]
-    --> tests/unit_tests/services/test_dataset_service_document.py:1551:22
+    --> tests/unit_tests/services/test_dataset_service_document.py:1578:22
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset_process_rule` with type `DatasetProcessRule | None` in function `services.dataset_service.DocumentService.save_document_with_dataset_id` [bad-argument-type]
-    --> tests/unit_tests/services/test_dataset_service_document.py:1665:42
+    --> tests/unit_tests/services/test_dataset_service_document.py:1692:42
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset_process_rule` with type `DatasetProcessRule | None` in function `services.dataset_service.DocumentService.save_document_with_dataset_id` [bad-argument-type]
-    --> tests/unit_tests/services/test_dataset_service_document.py:1688:42
+    --> tests/unit_tests/services/test_dataset_service_document.py:1715:42
 ERROR Argument `SimpleNamespace` is not assignable to parameter `knowledge_config` with type `KnowledgeConfig` in function `services.dataset_service.DocumentService.save_document_with_dataset_id` [bad-argument-type]
    --> tests/unit_tests/services/test_dataset_service_lock_not_owned.py:103:26
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `services.dataset_service.SegmentService.create_child_chunk` [bad-argument-type]
-  --> tests/unit_tests/services/test_dataset_service_segment.py:54:97
+  --> tests/unit_tests/services/test_dataset_service_segment.py:88:97
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `services.dataset_service.SegmentService.create_child_chunk` [bad-argument-type]
-  --> tests/unit_tests/services/test_dataset_service_segment.py:82:87
+   --> tests/unit_tests/services/test_dataset_service_segment.py:116:87
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `services.dataset_service.SegmentService.update_child_chunks` [bad-argument-type]
-   --> tests/unit_tests/services/test_dataset_service_segment.py:129:17
+   --> tests/unit_tests/services/test_dataset_service_segment.py:163:17
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `services.dataset_service.SegmentService.update_child_chunks` [bad-argument-type]
-   --> tests/unit_tests/services/test_dataset_service_segment.py:166:21
+   --> tests/unit_tests/services/test_dataset_service_segment.py:200:21
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `services.dataset_service.SegmentService.update_child_chunk` [bad-argument-type]
-   --> tests/unit_tests/services/test_dataset_service_segment.py:182:80
+   --> tests/unit_tests/services/test_dataset_service_segment.py:216:80
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `services.dataset_service.SegmentService.delete_child_chunk` [bad-argument-type]
-   --> tests/unit_tests/services/test_dataset_service_segment.py:205:64
+   --> tests/unit_tests/services/test_dataset_service_segment.py:239:64
 ERROR Argument `SimpleNamespace` is not assignable to parameter `segment` with type `DocumentSegment` in function `services.dataset_service.SegmentService.update_child_chunk` [bad-argument-type]
-   --> tests/unit_tests/services/test_dataset_service_segment.py:811:49
+   --> tests/unit_tests/services/test_dataset_service_segment.py:888:49
 ERROR Argument `SimpleNamespace` is not assignable to parameter `document` with type `Document` in function `services.dataset_service.SegmentService.update_child_chunk` [bad-argument-type]
-   --> tests/unit_tests/services/test_dataset_service_segment.py:811:68
+   --> tests/unit_tests/services/test_dataset_service_segment.py:888:68
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `services.dataset_service.SegmentService.update_child_chunk` [bad-argument-type]
-   --> tests/unit_tests/services/test_dataset_service_segment.py:811:87
+   --> tests/unit_tests/services/test_dataset_service_segment.py:888:87
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `services.dataset_service.SegmentService.delete_child_chunk` [bad-argument-type]
-   --> tests/unit_tests/services/test_dataset_service_segment.py:825:60
+   --> tests/unit_tests/services/test_dataset_service_segment.py:902:60
 ERROR Argument `str` is not assignable to parameter `type` with type `Literal['basic', 'bearer', 'custom'] | None` in function `services.entities.external_knowledge_entities.external_knowledge_entities.AuthorizationConfig.__init__` [bad-argument-type]
    --> tests/unit_tests/services/test_external_dataset_service.py:118:60
 ERROR Argument `str` is not assignable to parameter `type` with type `Literal['api-key', 'no-auth']` in function `services.entities.external_knowledge_entities.external_knowledge_entities.Authorization.__init__` [bad-argument-type]
@@ -7538,13 +7546,17 @@
 ERROR `Literal['2']` is not assignable to TypedDict key `limit` with type `int` [bad-typed-dict-key]
    --> tests/unit_tests/services/test_workflow_run_service.py:132:103
 ERROR Argument `dict[str, dict[str, str | dict[str, str]] | str]` is not assignable to parameter `object` with type `dict[str, dict[str, list[Unknown] | str] | str]` in function `list.append` [bad-argument-type]
-   --> tests/unit_tests/services/test_workflow_service.py:224:13
+   --> tests/unit_tests/services/test_workflow_service.py:225:13
+ERROR Argument `SimpleNamespace` is not assignable to parameter `app` with type `App` in function `services.workflow_ref_service.WorkflowRefService.create_app_workflow_ref` [bad-argument-type]
+    --> tests/unit_tests/services/test_workflow_service.py:1063:13
+ERROR Argument `SimpleNamespace` is not assignable to parameter `app` with type `App` in function `services.workflow_ref_service.WorkflowRefService.create_app_workflow_ref` [bad-argument-type]
+    --> tests/unit_tests/services/test_workflow_service.py:1128:13
 ERROR Missing required key `id` for TypedDict `NodeConfigDict` [bad-typed-dict-key]
-    --> tests/unit_tests/services/test_workflow_service.py:2790:71
+    --> tests/unit_tests/services/test_workflow_service.py:2852:71
 ERROR Missing required key `data` for TypedDict `NodeConfigDict` [bad-typed-dict-key]
-    --> tests/unit_tests/services/test_workflow_service.py:2790:71
+    --> tests/unit_tests/services/test_workflow_service.py:2852:71
 ERROR Argument `dict[str, str | dict[str, str]]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.workflow_service.WorkflowService._build_human_input_node_for_debugging` [bad-argument-type]
-    --> tests/unit_tests/services/test_workflow_service.py:2878:65
+    --> tests/unit_tests/services/test_workflow_service.py:2940:65
 ERROR Argument `Literal['api_key']` is not assignable to parameter `credential_type` with type `CredentialType` in function `services.tools.builtin_tools_manage_service.BuiltinToolManageService.list_builtin_provider_credentials_schema` [bad-argument-type]
   --> tests/unit_tests/services/tools/test_builtin_tools_manage_service.py:91:89
 ERROR Object of class `Mapping` has no attribute `startswith` [missing-attribute]

@WH-2099 WH-2099 marked this pull request as ready for review June 29, 2026 20:04
@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. refactor labels Jun 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 51.50% 51.54% +0.04%
Strict coverage 51.01% 51.05% +0.04%
Typed symbols 30,849 30,919 +70
Untyped symbols 29,332 29,350 +18
Modules 2931 2934 +3

@WH-2099 WH-2099 enabled auto-merge June 29, 2026 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant