Skip to content

refactor: explicit DB session propagation across backend paths#38559

Open
41tair wants to merge 23 commits into
langgenius:mainfrom
41tair:db-session-annotation
Open

refactor: explicit DB session propagation across backend paths#38559
41tair wants to merge 23 commits into
langgenius:mainfrom
41tair:db-session-annotation

Conversation

@41tair

@41tair 41tair commented Jul 8, 2026

Copy link
Copy Markdown
Member

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

#37403

Screenshots

Before After
... ...

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint && make type-check (backend) and cd web && pnpm exec vp staged (frontend) to appease the lint gods

@dosubot dosubot Bot added size:XXL This PR changes 1000+ lines, ignoring generated files. refactor labels Jul 8, 2026
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-07-11 14:38:25.548875273 +0000
+++ /tmp/pyrefly_pr.txt	2026-07-11 14:38:10.642702883 +0000
@@ -833,21 +833,21 @@
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
    --> tests/test_containers_integration_tests/services/test_annotation_service.py:107:81
 ERROR Argument `dict[str, str | Unknown | None]` is not assignable to parameter `args` with type `InsertAnnotationArgs` in function `services.annotation_service.AppAnnotationService.insert_app_annotation_directly` [bad-argument-type]
-   --> tests/test_containers_integration_tests/services/test_annotation_service.py:247:17
+   --> tests/test_containers_integration_tests/services/test_annotation_service.py:246:65
 ERROR Object of class `str` has no attribute `decode` [missing-attribute]
-   --> tests/test_containers_integration_tests/services/test_annotation_service.py:762:33
+   --> tests/test_containers_integration_tests/services/test_annotation_service.py:732:33
 ERROR Object of class `int` has no attribute `lower` [missing-attribute]
-   --> tests/test_containers_integration_tests/services/test_annotation_service.py:996:27
+   --> tests/test_containers_integration_tests/services/test_annotation_service.py:962:27
 ERROR Object of class `int` has no attribute `lower` [missing-attribute]
-    --> tests/test_containers_integration_tests/services/test_annotation_service.py:1044:27
+    --> tests/test_containers_integration_tests/services/test_annotation_service.py:1008:27
 ERROR TypedDict `AnnotationSettingDisabledDict` does not have key `id` [bad-typed-dict-key]
-    --> tests/test_containers_integration_tests/services/test_annotation_service.py:1086:23
+    --> tests/test_containers_integration_tests/services/test_annotation_service.py:1050:23
 ERROR TypedDict `AnnotationSettingDisabledDict` does not have key `score_threshold` [bad-typed-dict-key]
-    --> tests/test_containers_integration_tests/services/test_annotation_service.py:1087:23
+    --> tests/test_containers_integration_tests/services/test_annotation_service.py:1051:23
 ERROR TypedDict `AnnotationSettingDisabledDict` does not have key `embedding_model` [bad-typed-dict-key]
-    --> tests/test_containers_integration_tests/services/test_annotation_service.py:1088:23
+    --> tests/test_containers_integration_tests/services/test_annotation_service.py:1052:23
 ERROR TypedDict `AnnotationSettingDisabledDict` does not have key `embedding_model` [bad-typed-dict-key]
-    --> tests/test_containers_integration_tests/services/test_annotation_service.py:1089:23
+    --> tests/test_containers_integration_tests/services/test_annotation_service.py:1053:23
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
    --> tests/test_containers_integration_tests/services/test_api_based_extension_service.py:226:17
 ERROR Argument `None` is not assignable to parameter `value` with type `SQLCoreOperations[str] | str` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
@@ -1527,77 +1527,73 @@
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
    --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:223:23
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:273:27
+   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:274:27
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:285:27
+   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:286:27
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:356:23
+   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:357:23
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:368:23
+   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:369:23
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:439:23
+   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:440:23
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:456:27
+   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:457:27
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:541:23
+   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:542:23
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:553:23
+   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:554:23
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:642:23
+   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:643:23
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:654:23
+   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:655:23
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:735:23
+   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:736:23
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:753:27
+   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:754:27
 ERROR `num_segments_per_doc` may be uninitialized [unbound-name]
-   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:796:32
+   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:797:32
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:843:27
+   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:844:27
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:861:27
+   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:862:27
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:882:31
-ERROR `>=` is not supported between `None` and `Literal[3]` [unsupported-operation]
-   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:901:16
-ERROR `>=` is not supported between `None` and `Literal[9]` [unsupported-operation]
-   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:902:16
+   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:883:31
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:948:23
+   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:951:23
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:974:27
+   --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:977:27
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-    --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:1054:23
+    --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:1057:23
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-    --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:1067:23
+    --> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:1070:23
 ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
    --> tests/test_containers_integration_tests/tasks/test_deal_dataset_vector_index_task.py:227:16
 ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
    --> tests/test_containers_integration_tests/tasks/test_deal_dataset_vector_index_task.py:328:16
 ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_deal_dataset_vector_index_task.py:437:16
+   --> tests/test_containers_integration_tests/tasks/test_deal_dataset_vector_index_task.py:443:16
 ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_deal_dataset_vector_index_task.py:569:16
+   --> tests/test_containers_integration_tests/tasks/test_deal_dataset_vector_index_task.py:581:16
 ERROR Object of class `NoneType` has no attribute `error` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_deal_dataset_vector_index_task.py:570:52
+   --> tests/test_containers_integration_tests/tasks/test_deal_dataset_vector_index_task.py:582:52
 ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_deal_dataset_vector_index_task.py:640:16
+   --> tests/test_containers_integration_tests/tasks/test_deal_dataset_vector_index_task.py:652:16
 ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_deal_dataset_vector_index_task.py:716:16
+   --> tests/test_containers_integration_tests/tasks/test_deal_dataset_vector_index_task.py:728:16
 ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_deal_dataset_vector_index_task.py:923:16
+   --> tests/test_containers_integration_tests/tasks/test_deal_dataset_vector_index_task.py:935:16
 ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
-    --> tests/test_containers_integration_tests/tasks/test_deal_dataset_vector_index_task.py:1033:16
+    --> tests/test_containers_integration_tests/tasks/test_deal_dataset_vector_index_task.py:1045:16
 ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
-    --> tests/test_containers_integration_tests/tasks/test_deal_dataset_vector_index_task.py:1039:16
+    --> tests/test_containers_integration_tests/tasks/test_deal_dataset_vector_index_task.py:1051:16
 ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
-    --> tests/test_containers_integration_tests/tasks/test_deal_dataset_vector_index_task.py:1154:16
+    --> tests/test_containers_integration_tests/tasks/test_deal_dataset_vector_index_task.py:1166:16
 ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
-    --> tests/test_containers_integration_tests/tasks/test_deal_dataset_vector_index_task.py:1160:16
+    --> tests/test_containers_integration_tests/tasks/test_deal_dataset_vector_index_task.py:1172:16
 ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
-    --> tests/test_containers_integration_tests/tasks/test_deal_dataset_vector_index_task.py:1275:16
+    --> tests/test_containers_integration_tests/tasks/test_deal_dataset_vector_index_task.py:1287:16
 ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
-    --> tests/test_containers_integration_tests/tasks/test_deal_dataset_vector_index_task.py:1281:16
+    --> tests/test_containers_integration_tests/tasks/test_deal_dataset_vector_index_task.py:1293:16
 ERROR Argument `Literal['active']` is not assignable to parameter `status` with type `AccountStatus | SQLCoreOperations[AccountStatus]` in function `models.account.Account.__init__` [bad-argument-type]
   --> tests/test_containers_integration_tests/tasks/test_disable_segment_from_index_task.py:56:20
 ERROR Argument `Literal['normal']` is not assignable to parameter `status` with type `SQLCoreOperations[TenantStatus] | TenantStatus` in function `models.account.Tenant.__init__` [bad-argument-type]
@@ -1615,45 +1611,33 @@
 ERROR `str | None` is not assignable to upper bound `SupportsDunderGT[Any] | SupportsDunderLT[Any]` of type variable `SupportsRichComparisonT` [bad-specialization]
    --> tests/test_containers_integration_tests/tasks/test_disable_segments_from_index_task.py:725:57
 ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_document_indexing_task.py:258:20
+   --> tests/test_containers_integration_tests/tasks/test_document_indexing_task.py:271:20
 ERROR Object of class `NoneType` has no attribute `processing_started_at` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_document_indexing_task.py:259:20
+   --> tests/test_containers_integration_tests/tasks/test_document_indexing_task.py:272:20
 ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_document_indexing_task.py:328:20
+   --> tests/test_containers_integration_tests/tasks/test_document_indexing_task.py:341:20
 ERROR Object of class `NoneType` has no attribute `processing_started_at` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_document_indexing_task.py:329:20
+   --> tests/test_containers_integration_tests/tasks/test_document_indexing_task.py:342:20
 ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_document_indexing_task.py:375:20
+   --> tests/test_containers_integration_tests/tasks/test_document_indexing_task.py:461:20
 ERROR Object of class `NoneType` has no attribute `processing_started_at` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_document_indexing_task.py:376:20
+   --> tests/test_containers_integration_tests/tasks/test_document_indexing_task.py:462:20
 ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_document_indexing_task.py:452:20
-ERROR Object of class `NoneType` has no attribute `processing_started_at` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_document_indexing_task.py:453:20
-ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_document_indexing_task.py:515:20
+   --> tests/test_containers_integration_tests/tasks/test_document_indexing_task.py:524:20
 ERROR Object of class `NoneType` has no attribute `error` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_document_indexing_task.py:516:20
+   --> tests/test_containers_integration_tests/tasks/test_document_indexing_task.py:525:20
 ERROR `in` is not supported between `Literal['batch upload']` and `object` [not-iterable]
-   --> tests/test_containers_integration_tests/tasks/test_document_indexing_task.py:517:20
+   --> tests/test_containers_integration_tests/tasks/test_document_indexing_task.py:526:20
 ERROR Object of class `NoneType` has no attribute `stopped_at` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_document_indexing_task.py:518:20
-ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_document_indexing_task.py:556:20
-ERROR Object of class `NoneType` has no attribute `processing_started_at` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_document_indexing_task.py:557:20
-ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_document_indexing_task.py:599:20
-ERROR Object of class `NoneType` has no attribute `processing_started_at` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_document_indexing_task.py:600:20
+   --> tests/test_containers_integration_tests/tasks/test_document_indexing_task.py:527:20
 ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_document_indexing_task.py:712:20
+   --> tests/test_containers_integration_tests/tasks/test_document_indexing_task.py:565:20
 ERROR Object of class `NoneType` has no attribute `processing_started_at` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_document_indexing_task.py:713:20
+   --> tests/test_containers_integration_tests/tasks/test_document_indexing_task.py:566:20
 ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_document_indexing_task.py:837:20
+   --> tests/test_containers_integration_tests/tasks/test_document_indexing_task.py:717:20
 ERROR Object of class `NoneType` has no attribute `processing_started_at` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_document_indexing_task.py:838:20
+   --> tests/test_containers_integration_tests/tasks/test_document_indexing_task.py:718:20
 ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
    --> tests/test_containers_integration_tests/tasks/test_document_indexing_update_task.py:129:16
 ERROR Object of class `NoneType` has no attribute `processing_started_at` [missing-attribute]
@@ -1661,59 +1645,55 @@
 ERROR `>` is not supported between `None` and `Literal[0]` [unsupported-operation]
    --> tests/test_containers_integration_tests/tasks/test_document_indexing_update_task.py:177:16
 ERROR Argument `Literal['active']` is not assignable to parameter `status` with type `AccountStatus | SQLCoreOperations[AccountStatus]` in function `models.account.Account.__init__` [bad-argument-type]
-  --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:86:20
+  --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:99:20
 ERROR Argument `Literal['normal']` is not assignable to parameter `status` with type `SQLCoreOperations[TenantStatus] | TenantStatus` in function `models.account.Tenant.__init__` [bad-argument-type]
-  --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:93:20
+   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:106:20
 ERROR Argument `Literal['active']` is not assignable to parameter `status` with type `AccountStatus | SQLCoreOperations[AccountStatus]` in function `models.account.Account.__init__` [bad-argument-type]
-   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:224:20
+   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:237:20
 ERROR Argument `Literal['normal']` is not assignable to parameter `status` with type `SQLCoreOperations[TenantStatus] | TenantStatus` in function `models.account.Tenant.__init__` [bad-argument-type]
-   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:231:20
+   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:244:20
 ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:326:20
+   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:339:20
 ERROR Object of class `NoneType` has no attribute `processing_started_at` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:327:20
+   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:340:20
 ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:378:20
+   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:391:20
 ERROR Object of class `NoneType` has no attribute `processing_started_at` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:379:20
+   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:392:20
 ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:447:20
+   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:460:20
 ERROR Object of class `NoneType` has no attribute `processing_started_at` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:448:20
+   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:461:20
 ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:494:20
-ERROR Object of class `NoneType` has no attribute `processing_started_at` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:495:20
-ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:552:20
+   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:561:20
 ERROR Object of class `NoneType` has no attribute `error` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:553:20
+   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:562:20
 ERROR Object of class `object` has no attribute `lower` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:554:38
+   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:563:38
 ERROR Object of class `NoneType` has no attribute `stopped_at` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:555:20
+   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:564:20
 ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:594:20
+   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:603:20
 ERROR Object of class `NoneType` has no attribute `error` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:595:20
+   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:604:20
 ERROR Object of class `object` has no attribute `lower` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:596:31
+   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:605:31
 ERROR Object of class `NoneType` has no attribute `stopped_at` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:597:20
+   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:606:20
 ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:658:20
+   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:668:20
 ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:701:20
+   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:711:20
 ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:745:20
+   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:755:20
 ERROR Object of class `NoneType` has no attribute `is_paused` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:860:20
+   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:870:20
 ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:861:20
+   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:871:20
 ERROR Object of class `NoneType` has no attribute `display_status` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:862:20
+   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:872:20
 ERROR Object of class `NoneType` has no attribute `processing_started_at` [missing-attribute]
-   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:863:20
+   --> tests/test_containers_integration_tests/tasks/test_duplicate_document_indexing_task.py:873:20
 ERROR Argument `Literal['active']` is not assignable to parameter `status` with type `AccountStatus | SQLCoreOperations[AccountStatus]` in function `models.account.Account.__init__` [bad-argument-type]
   --> tests/test_containers_integration_tests/tasks/test_enable_segments_to_index_task.py:55:20
 ERROR Argument `Literal['normal']` is not assignable to parameter `status` with type `SQLCoreOperations[TenantStatus] | TenantStatus` in function `models.account.Tenant.__init__` [bad-argument-type]
@@ -1886,96 +1866,88 @@
    --> tests/unit_tests/controllers/common/test_agent_app_parameters.py:165:95
 ERROR No attribute `MethodView` in module `builtins` [missing-attribute]
  --> tests/unit_tests/controllers/common/test_fields.py:8:5
-ERROR Cannot index into `object` [bad-index]
-   --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:715:12
-ERROR Cannot index into `object` [bad-index]
-   --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:716:12
-ERROR Cannot index into `object` [bad-index]
-   --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:717:12
-ERROR Cannot index into `object` [bad-index]
-   --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:718:12
 ERROR `in` is not supported between `Literal['Incorrect API key provided']` and `None` [not-iterable]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1471:12
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1337:12
 ERROR Argument `SimpleNamespace` is not assignable to parameter `current_user` with type `Account` in function `controllers.console.app.completion._create_build_chat_finalization_message` [bad-argument-type]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1557:26
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1412:26
 ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `controllers.console.app.completion._create_build_chat_finalization_message` [bad-argument-type]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1558:23
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1413:23
 ERROR Argument `test_drain_streaming_generate_response_returns_on_message_end.ClosableResponse` is not assignable to parameter `response` with type `Generator[str] | RateLimitGenerator` in function `controllers.console.app.completion._drain_streaming_generate_response` [bad-argument-type]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1606:69
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1461:69
 ERROR Argument `Iterator[Any]` is not assignable to parameter `response` with type `Generator[str] | RateLimitGenerator` in function `controllers.console.app.completion._drain_streaming_generate_response` [bad-argument-type]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1614:66
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1468:66
 ERROR Argument `Iterator[Any]` is not assignable to parameter `response` with type `Generator[str] | RateLimitGenerator` in function `controllers.console.app.completion._drain_streaming_generate_response` [bad-argument-type]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1621:66
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1474:66
 ERROR Argument `SimpleNamespace` is not assignable to parameter `current_user` with type `Account` in function `controllers.console.app.completion._create_chat_message` [bad-argument-type]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1652:26
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1501:26
 ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `controllers.console.app.completion._create_chat_message` [bad-argument-type]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1653:23
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1501:50
 ERROR Argument `SimpleNamespace` is not assignable to parameter `current_user` with type `Account` in function `controllers.console.app.completion._create_chat_message` [bad-argument-type]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1700:26
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1546:26
 ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `controllers.console.app.completion._create_chat_message` [bad-argument-type]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1701:23
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1547:23
 ERROR Argument `SimpleNamespace` is not assignable to parameter `current_user` with type `Account` in function `controllers.console.app.completion._create_chat_message` [bad-argument-type]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1737:30
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1579:30
 ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `controllers.console.app.completion._create_chat_message` [bad-argument-type]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1738:27
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1580:27
 ERROR Argument `SimpleNamespace` is not assignable to parameter `current_user` with type `Account` in function `controllers.console.app.completion._resolve_current_user_agent_debug_conversation_id` [bad-argument-type]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1766:22
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1607:22
 ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `controllers.console.app.completion._resolve_current_user_agent_debug_conversation_id` [bad-argument-type]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1767:19
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1608:19
 ERROR Argument `SimpleNamespace` is not assignable to parameter `current_user` with type `Account` in function `controllers.console.app.completion._resolve_current_user_agent_debug_conversation_id` [bad-argument-type]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1772:22
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1614:22
 ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `controllers.console.app.completion._resolve_current_user_agent_debug_conversation_id` [bad-argument-type]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1773:19
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1615:19
 ERROR Argument `SimpleNamespace` is not assignable to parameter `current_user` with type `Account` in function `controllers.console.app.completion._create_chat_message` [bad-argument-type]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1824:30
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1661:30
 ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `controllers.console.app.completion._create_chat_message` [bad-argument-type]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1825:27
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1661:73
 ERROR Object of class `object` has no attribute `data` [missing-attribute]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1908:50
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1736:50
 ERROR Object of class `object` has no attribute `limit` [missing-attribute]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1909:30
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1737:30
 ERROR Object of class `object` has no attribute `has_more` [missing-attribute]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1910:33
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1738:33
 ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `controllers.console.app.message._list_chat_messages` [bad-argument-type]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1922:67
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1748:67
 ERROR Object of class `object` has no attribute `data` [missing-attribute]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1948:50
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1767:50
 ERROR Object of class `object` has no attribute `limit` [missing-attribute]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1949:30
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1768:30
 ERROR Object of class `object` has no attribute `has_more` [missing-attribute]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1950:33
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1769:33
 ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `controllers.console.app.message._list_chat_messages` [bad-argument-type]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1974:67
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1792:67
 ERROR Argument `SimpleNamespace` is not assignable to parameter `current_user` with type `Account | None` in function `controllers.console.app.message._list_chat_messages` [bad-argument-type]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1974:91
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1792:91
 ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `controllers.console.app.message._list_chat_messages` [bad-argument-type]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1995:27
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1808:27
 ERROR Argument `SimpleNamespace` is not assignable to parameter `current_user` with type `Account | None` in function `controllers.console.app.message._list_chat_messages` [bad-argument-type]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1996:30
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1808:83
 ERROR Argument `SimpleNamespace` is not assignable to parameter `current_user` with type `Account` in function `controllers.console.app.message._update_message_feedback` [bad-argument-type]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:2011:30
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1822:30
 ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `controllers.console.app.message._update_message_feedback` [bad-argument-type]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:2012:27
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1822:73
 ERROR Argument `SimpleNamespace` is not assignable to parameter `current_user` with type `Account` in function `controllers.console.app.message._get_message_suggested_questions` [bad-argument-type]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:2048:26
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1855:26
 ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `controllers.console.app.message._get_message_suggested_questions` [bad-argument-type]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:2049:23
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1856:23
 ERROR Argument `Literal['00000000-0000-0000-0000-000000000002']` is not assignable to parameter `message_id` with type `UUID` in function `controllers.console.app.message._get_message_suggested_questions` [bad-argument-type]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:2050:24
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1857:24
 ERROR Object of class `int` has no attribute `lower` [missing-attribute]
-   --> tests/unit_tests/controllers/console/app/test_annotation_security.py:219:38
+   --> tests/unit_tests/controllers/console/app/test_annotation_security.py:220:38
 ERROR Object of class `int` has no attribute `lower` [missing-attribute]
-   --> tests/unit_tests/controllers/console/app/test_annotation_security.py:219:82
+   --> tests/unit_tests/controllers/console/app/test_annotation_security.py:220:82
 ERROR Object of class `int` has no attribute `lower` [missing-attribute]
-   --> tests/unit_tests/controllers/console/app/test_annotation_security.py:236:34
+   --> tests/unit_tests/controllers/console/app/test_annotation_security.py:237:34
 ERROR Object of class `int` has no attribute `lower` [missing-attribute]
-   --> tests/unit_tests/controllers/console/app/test_annotation_security.py:236:78
+   --> tests/unit_tests/controllers/console/app/test_annotation_security.py:237:78
 ERROR Object of class `int` has no attribute `lower` [missing-attribute]
-   --> tests/unit_tests/controllers/console/app/test_annotation_security.py:254:35
+   --> tests/unit_tests/controllers/console/app/test_annotation_security.py:255:35
 ERROR Argument `SimpleNamespace` is not assignable to parameter `current_user` with type `Account` in function `controllers.console.app.conversation._get_conversation` [bad-argument-type]
-  --> tests/unit_tests/controllers/console/app/test_conversation_api.py:90:52
+  --> tests/unit_tests/controllers/console/app/test_conversation_api.py:74:61
 ERROR Argument `SimpleNamespace` is not assignable to parameter `current_user` with type `Account` in function `controllers.console.app.conversation._get_conversation` [bad-argument-type]
-   --> tests/unit_tests/controllers/console/app/test_conversation_api.py:105:47
+  --> tests/unit_tests/controllers/console/app/test_conversation_api.py:85:56
 ERROR Missing argument `app_model` in function `handler` [missing-argument]
   --> tests/unit_tests/controllers/console/app/test_wraps.py:41:19
 ERROR Unexpected keyword argument `app_id` in function `handler` [unexpected-keyword]
@@ -2141,25 +2113,25 @@
 ERROR Missing argument `payload` in function `protected_view` [missing-argument]
    --> tests/unit_tests/controllers/inner_api/plugin/test_plugin_wraps.py:380:36
 ERROR Object of class `FunctionType` has no attribute `view_class` [missing-attribute]
-  --> tests/unit_tests/controllers/openapi/test_account.py:47:12
+  --> tests/unit_tests/controllers/openapi/test_account.py:46:12
 ERROR Object of class `FunctionType` has no attribute `view_class` [missing-attribute]
-  --> tests/unit_tests/controllers/openapi/test_account.py:57:12
+  --> tests/unit_tests/controllers/openapi/test_account.py:56:12
 ERROR `in` is not supported between `Literal['GET']` and `None` [not-iterable]
-  --> tests/unit_tests/controllers/openapi/test_account.py:62:12
+  --> tests/unit_tests/controllers/openapi/test_account.py:61:12
 ERROR `in` is not supported between `Literal['DELETE']` and `None` [not-iterable]
-  --> tests/unit_tests/controllers/openapi/test_account.py:67:12
+  --> tests/unit_tests/controllers/openapi/test_account.py:66:12
 ERROR Object of class `FunctionType` has no attribute `view_class` [missing-attribute]
-  --> tests/unit_tests/controllers/openapi/test_account.py:77:12
+  --> tests/unit_tests/controllers/openapi/test_account.py:76:12
 ERROR `in` is not supported between `Literal['GET']` and `None` [not-iterable]
-  --> tests/unit_tests/controllers/openapi/test_account.py:78:12
+  --> tests/unit_tests/controllers/openapi/test_account.py:77:12
 ERROR Object of class `FunctionType` has no attribute `view_class` [missing-attribute]
-  --> tests/unit_tests/controllers/openapi/test_account.py:88:12
+  --> tests/unit_tests/controllers/openapi/test_account.py:87:12
 ERROR `in` is not supported between `Literal['DELETE']` and `None` [not-iterable]
-  --> tests/unit_tests/controllers/openapi/test_account.py:89:12
+  --> tests/unit_tests/controllers/openapi/test_account.py:88:12
 ERROR Argument `frozenset[str]` is not assignable to parameter `scopes` with type `frozenset[Scope]` in function `libs.oauth_bearer.AuthContext.__init__` [bad-argument-type]
-   --> tests/unit_tests/controllers/openapi/test_account.py:106:16
+   --> tests/unit_tests/controllers/openapi/test_account.py:105:16
 ERROR Argument `frozenset[str]` is not assignable to parameter `scopes` with type `frozenset[Scope]` in function `libs.oauth_bearer.AuthContext.__init__` [bad-argument-type]
-   --> tests/unit_tests/controllers/openapi/test_account.py:135:16
+   --> tests/unit_tests/controllers/openapi/test_account.py:134:16
 ERROR Argument `_FakeApp` is not assignable to parameter `app` with type `App` in function `controllers.openapi.apps.build_app_describe_response` [bad-argument-type]
   --> tests/unit_tests/controllers/openapi/test_app_describe_builder.py:30:40
 ERROR Argument `_FakeApp` is not assignable to parameter `app` with type `App` in function `controllers.openapi.apps.build_app_describe_response` [bad-argument-type]
@@ -2231,21 +2203,11 @@
 ERROR `in` is not supported between `Literal['GET']` and `None` [not-iterable]
   --> tests/unit_tests/controllers/openapi/test_workspaces.py:50:12
 ERROR Object of class `FunctionType` has no attribute `view_class` [missing-attribute]
-   --> tests/unit_tests/controllers/openapi/test_workspaces_members.py:184:12
-ERROR `in` is not supported between `Literal['POST']` and `None` [not-iterable]
    --> tests/unit_tests/controllers/openapi/test_workspaces_members.py:185:12
 ERROR Object of class `FunctionType` has no attribute `view_class` [missing-attribute]
-   --> tests/unit_tests/controllers/openapi/test_workspaces_members.py:190:12
-ERROR `in` is not supported between `Literal['GET']` and `None` [not-iterable]
-   --> tests/unit_tests/controllers/openapi/test_workspaces_members.py:191:12
-ERROR `in` is not supported between `Literal['POST']` and `None` [not-iterable]
    --> tests/unit_tests/controllers/openapi/test_workspaces_members.py:192:12
 ERROR Object of class `FunctionType` has no attribute `view_class` [missing-attribute]
-   --> tests/unit_tests/controllers/openapi/test_workspaces_members.py:197:12
-ERROR `in` is not supported between `Literal['DELETE']` and `None` [not-iterable]
-   --> tests/unit_tests/controllers/openapi/test_workspaces_members.py:198:12
-ERROR `in` is not supported between `Literal['PATCH']` and `None` [not-iterable]
-   --> tests/unit_tests/controllers/openapi/test_workspaces_members.py:199:12
+   --> tests/unit_tests/controllers/openapi/test_workspaces_members.py:200:12
 ERROR Cannot index into `Iterable[bytes]` [bad-index]
    --> tests/unit_tests/controllers/service_api/app/test_audio.py:186:16
 ERROR Cannot index into `Response` [bad-index]
@@ -2285,11 +2247,11 @@
 ERROR Argument `() -> TestHitlServiceApi.test_snapshot_events_include_pause_payload_contract._SessionContext` is not assignable to parameter `session_maker` with type `sessionmaker[Session] | None` in function `services.workflow_event_snapshot_service._build_snapshot_events` [bad-argument-type]
    --> tests/unit_tests/controllers/service_api/app/test_hitl_service_api.py:703:27
 ERROR No matching overload found for function `typing.MutableMapping.update` called with arguments: (dict[str, object]) [no-matching-overload]
-   --> tests/unit_tests/controllers/service_api/dataset/test_document.py:155:17
+   --> tests/unit_tests/controllers/service_api/dataset/test_document.py:165:17
 ERROR Object of class `Document` has no attribute `summary_index_status` [missing-attribute]
-   --> tests/unit_tests/controllers/service_api/dataset/test_document.py:185:33
+   --> tests/unit_tests/controllers/service_api/dataset/test_document.py:195:33
 ERROR Missing argument `session` in function `services.dataset_service.DocumentService.get_document` [missing-argument]
-   --> tests/unit_tests/controllers/service_api/dataset/test_document.py:377:46
+   --> tests/unit_tests/controllers/service_api/dataset/test_document.py:387:46
 ERROR Missing argument `app_model` in function `protected_view` [missing-argument]
    --> tests/unit_tests/controllers/service_api/test_wraps.py:160:36
 ERROR Cannot index into `object` [bad-index]
@@ -3088,33 +3050,33 @@
 ERROR `TestAdvancedChatGenerateTaskPipeline.test_handle_output_moderation_chunk_appends_token._Moderation` is not assignable to attribute `output_moderation_handler` with type `OutputModeration | None` [bad-assignment]
    --> tests/unit_tests/core/app/apps/advanced_chat/test_generate_task_pipeline_core.py:576:66
 ERROR `(**kwargs: Unknown) -> Literal['replace']` is not assignable to attribute `message_replace_to_stream_response` with type `(self: MessageCycleManager, answer: str, reason: str = '') -> MessageReplaceStreamResponse` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/advanced_chat/test_generate_task_pipeline_core.py:605:78
+   --> tests/unit_tests/core/app/apps/advanced_chat/test_generate_task_pipeline_core.py:611:78
 ERROR `(**kwargs: Unknown) -> Literal['filled']` is not assignable to attribute `human_input_form_filled_to_stream_response` with type `(self: WorkflowResponseConverter, *, event: QueueHumanInputFormFilledEvent, task_id: str) -> HumanInputFormFilledResponse` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/advanced_chat/test_generate_task_pipeline_core.py:618:92
+   --> tests/unit_tests/core/app/apps/advanced_chat/test_generate_task_pipeline_core.py:624:92
 ERROR `(**kwargs: Unknown) -> Literal['timeout']` is not assignable to attribute `human_input_form_timeout_to_stream_response` with type `(self: WorkflowResponseConverter, *, event: QueueHumanInputFormTimeoutEvent, task_id: str) -> HumanInputFormTimeoutResponse` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/advanced_chat/test_generate_task_pipeline_core.py:619:93
+   --> tests/unit_tests/core/app/apps/advanced_chat/test_generate_task_pipeline_core.py:625:93
 ERROR Argument `TestAdvancedChatGenerateTaskPipeline.test_save_message_preserves_full_answer_and_sets_usage._Session` is not assignable to parameter `session` with type `Session` in function `core.app.apps.advanced_chat.generate_task_pipeline.AdvancedChatAppGenerateTaskPipeline._save_message` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/advanced_chat/test_generate_task_pipeline_core.py:691:40
+   --> tests/unit_tests/core/app/apps/advanced_chat/test_generate_task_pipeline_core.py:697:40
 ERROR `() -> Literal['end']` is not assignable to attribute `_message_end_to_stream_response` with type `(self: AdvancedChatAppGenerateTaskPipeline) -> MessageEndStreamResponse` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/advanced_chat/test_generate_task_pipeline_core.py:699:52
+   --> tests/unit_tests/core/app/apps/advanced_chat/test_generate_task_pipeline_core.py:705:52
 ERROR `(answer: Unknown) -> Literal['safe']` is not assignable to attribute `handle_output_moderation_when_task_finished` with type `(self: BasedGenerateTaskPipeline[Unknown], completion: str) -> str | None` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/advanced_chat/test_generate_task_pipeline_core.py:726:84
+   --> tests/unit_tests/core/app/apps/advanced_chat/test_generate_task_pipeline_core.py:732:84
 ERROR `(**kwargs: Unknown) -> Literal['replace']` is not assignable to attribute `message_replace_to_stream_response` with type `(self: MessageCycleManager, answer: str, reason: str = '') -> MessageReplaceStreamResponse` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/advanced_chat/test_generate_task_pipeline_core.py:727:78
+   --> tests/unit_tests/core/app/apps/advanced_chat/test_generate_task_pipeline_core.py:733:78
 ERROR `() -> Literal['end']` is not assignable to attribute `_message_end_to_stream_response` with type `(self: AdvancedChatAppGenerateTaskPipeline) -> MessageEndStreamResponse` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/advanced_chat/test_generate_task_pipeline_core.py:728:52
+   --> tests/unit_tests/core/app/apps/advanced_chat/test_generate_task_pipeline_core.py:734:52
 ERROR `(**kwargs: Unknown) -> Literal['failed']` is not assignable to attribute `workflow_node_finish_to_stream_response` with type `(self: WorkflowResponseConverter, *, event: QueueNodeExceptionEvent | QueueNodeFailedEvent | QueueNodeSucceededEvent, task_id: str) -> NodeFinishStreamResponse | None` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/advanced_chat/test_generate_task_pipeline_core.py:750:89
+   --> tests/unit_tests/core/app/apps/advanced_chat/test_generate_task_pipeline_core.py:756:89
 ERROR Argument `DummyAccount` is not assignable to parameter `user` with type `Account | EndUser` in function `core.app.apps.agent_app.app_generator.AgentAppGenerator.generate` [bad-argument-type]
-  --> tests/unit_tests/core/app/apps/agent_app/test_app_generator.py:50:22
+  --> tests/unit_tests/core/app/apps/agent_app/test_app_generator.py:51:22
 ERROR Argument `DummyAccount` is not assignable to parameter `user` with type `Account | EndUser` in function `core.app.apps.agent_app.app_generator.AgentAppGenerator.generate` [bad-argument-type]
-  --> tests/unit_tests/core/app/apps/agent_app/test_app_generator.py:60:22
+  --> tests/unit_tests/core/app/apps/agent_app/test_app_generator.py:61:22
 ERROR Argument `DummyAccount` is not assignable to parameter `user` with type `Account | EndUser` in function `core.app.apps.agent_app.app_generator.AgentAppGenerator.generate` [bad-argument-type]
-  --> tests/unit_tests/core/app/apps/agent_app/test_app_generator.py:69:22
+  --> tests/unit_tests/core/app/apps/agent_app/test_app_generator.py:70:22
 ERROR Argument `DummyAccount` is not assignable to parameter `user` with type `Account | EndUser` in function `core.app.apps.agent_app.app_generator.AgentAppGenerator.generate` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/agent_app/test_app_generator.py:235:18
+   --> tests/unit_tests/core/app/apps/agent_app/test_app_generator.py:238:18
 ERROR Argument `DummyAccount` is not assignable to parameter `user` with type `Account | EndUser` in function `core.app.apps.agent_app.app_generator.AgentAppGenerator.generate` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/agent_app/test_app_generator.py:273:18
+   --> tests/unit_tests/core/app/apps/agent_app/test_app_generator.py:276:18
 ERROR Object of class `NoneType` has no attribute `message` [missing-attribute]
    --> tests/unit_tests/core/app/apps/agent_app/test_app_runner.py:515:12
 ERROR Object of class `NoneType` has no attribute `model` [missing-attribute]
@@ -3140,41 +3102,41 @@
 ERROR Object of class `NoneType` has no attribute `message` [missing-attribute]
    --> tests/unit_tests/core/app/apps/agent_app/test_app_runner.py:746:12
 ERROR Object of class `NoneType` has no attribute `message` [missing-attribute]
-  --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:67:12
+  --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:68:12
 ERROR Object of class `NoneType` has no attribute `prompt_messages` [missing-attribute]
-  --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:72:23
+  --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:73:23
 ERROR Argument `SimpleNamespace` is not assignable to parameter `application_generate_entity` with type `AgentAppGenerateEntity` in function `core.app.apps.agent_app.app_generator.AgentAppGenerator._run_input_guards` [bad-argument-type]
-  --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:84:41
+  --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:86:41
 ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `core.app.apps.agent_app.app_generator.AgentAppGenerator._run_input_guards` [bad-argument-type]
-  --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:85:23
+  --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:87:23
 ERROR Argument `SimpleNamespace` is not assignable to parameter `message` with type `Message` in function `core.app.apps.agent_app.app_generator.AgentAppGenerator._run_input_guards` [bad-argument-type]
-  --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:86:21
+  --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:88:21
 ERROR Argument `_FakeQueueManager` is not assignable to parameter `queue_manager` with type `AppQueueManager` in function `core.app.apps.agent_app.app_generator.AgentAppGenerator._run_input_guards` [bad-argument-type]
-  --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:87:27
+  --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:89:27
 ERROR Argument `SimpleNamespace` is not assignable to parameter `application_generate_entity` with type `AgentAppGenerateEntity` in function `core.app.apps.agent_app.app_generator.AgentAppGenerator._run_input_guards` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:100:41
+   --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:103:41
 ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `core.app.apps.agent_app.app_generator.AgentAppGenerator._run_input_guards` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:101:23
+   --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:104:23
 ERROR Argument `SimpleNamespace` is not assignable to parameter `message` with type `Message` in function `core.app.apps.agent_app.app_generator.AgentAppGenerator._run_input_guards` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:102:21
+   --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:105:21
 ERROR Argument `_FakeQueueManager` is not assignable to parameter `queue_manager` with type `AppQueueManager` in function `core.app.apps.agent_app.app_generator.AgentAppGenerator._run_input_guards` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:103:27
+   --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:106:27
 ERROR Argument `SimpleNamespace` is not assignable to parameter `application_generate_entity` with type `AgentAppGenerateEntity` in function `core.app.apps.agent_app.app_generator.AgentAppGenerator._run_input_guards` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:116:41
+   --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:120:41
 ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `core.app.apps.agent_app.app_generator.AgentAppGenerator._run_input_guards` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:117:23
+   --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:121:23
 ERROR Argument `SimpleNamespace` is not assignable to parameter `message` with type `Message` in function `core.app.apps.agent_app.app_generator.AgentAppGenerator._run_input_guards` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:118:21
+   --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:122:21
 ERROR Argument `_FakeQueueManager` is not assignable to parameter `queue_manager` with type `AppQueueManager` in function `core.app.apps.agent_app.app_generator.AgentAppGenerator._run_input_guards` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:119:27
+   --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:123:27
 ERROR Argument `SimpleNamespace` is not assignable to parameter `application_generate_entity` with type `AgentAppGenerateEntity` in function `core.app.apps.agent_app.app_generator.AgentAppGenerator._run_input_guards` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:133:41
+   --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:138:41
 ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `core.app.apps.agent_app.app_generator.AgentAppGenerator._run_input_guards` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:134:23
+   --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:139:23
 ERROR Argument `SimpleNamespace` is not assignable to parameter `message` with type `Message` in function `core.app.apps.agent_app.app_generator.AgentAppGenerator._run_input_guards` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:135:21
+   --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:140:21
 ERROR Argument `_FakeQueueManager` is not assignable to parameter `queue_manager` with type `AppQueueManager` in function `core.app.apps.agent_app.app_generator.AgentAppGenerator._run_input_guards` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:136:27
+   --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:141:27
 ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `core.app.apps.agent_app.app_generator.AgentAppGenerator._resolve_agent` [bad-argument-type]
   --> tests/unit_tests/core/app/apps/agent_app/test_resolve_agent.py:89:13
 ERROR Argument `SimpleNamespace` is not assignable to parameter `user` with type `Account | EndUser` in function `core.app.apps.agent_app.app_generator.AgentAppGenerator._resolve_agent` [bad-argument-type]
@@ -3241,13 +3203,13 @@
 ERROR Object of class `FromClause` has no attribute `drop` [missing-attribute]
   --> tests/unit_tests/core/app/apps/agent_app/test_session_store.py:63:5
 ERROR Argument `dict[str, dict[str, str]]` is not assignable to parameter `override_config_dict` with type `AppModelConfigDict | None` in function `core.app.apps.agent_chat.app_config_manager.AgentChatAppConfigManager.get_app_config` [bad-argument-type]
-  --> tests/unit_tests/core/app/apps/agent_chat/test_agent_chat_app_config_manager.py:41:34
+  --> tests/unit_tests/core/app/apps/agent_chat/test_agent_chat_app_config_manager.py:42:34
 ERROR Object of class `FunctionType` has no attribute `assert_called_once` [missing-attribute]
   --> tests/unit_tests/core/app/apps/agent_chat/test_agent_chat_app_runner.py:59:9
 ERROR Object of class `FunctionType` has no attribute `assert_called_once` [missing-attribute]
-  --> tests/unit_tests/core/app/apps/agent_chat/test_agent_chat_app_runner.py:88:9
+  --> tests/unit_tests/core/app/apps/agent_chat/test_agent_chat_app_runner.py:90:9
 ERROR Object of class `FunctionType` has no attribute `assert_called_once` [missing-attribute]
-   --> tests/unit_tests/core/app/apps/agent_chat/test_agent_chat_app_runner.py:207:9
+   --> tests/unit_tests/core/app/apps/agent_chat/test_agent_chat_app_runner.py:209:9
 ERROR Cannot index into `str` [bad-index]
    --> tests/unit_tests/core/app/apps/agent_chat/test_agent_chat_generate_response_converter.py:158:16
 ERROR Cannot index into `str` [bad-index]
@@ -3274,58 +3236,58 @@
   --> tests/unit_tests/core/app/apps/chat/test_app_generator_and_runner.py:50:31
 ERROR No matching overload found for function `core.app.apps.chat.app_generator.ChatAppGenerator.generate` called with arguments: (session=MagicMock, app_model=SimpleNamespace, user=SimpleNamespace, args=dict[str, dict[@_, @_] | int], invoke_from=Literal[InvokeFrom.SERVICE_API], streaming=Literal[False]) [no-matching-overload]
   --> tests/unit_tests/core/app/apps/chat/test_app_generator_and_runner.py:62:31
-ERROR No matching overload found for function `core.app.apps.chat.app_generator.ChatAppGenerator.generate` called with arguments: (MagicMock, SimpleNamespace, SimpleNamespace, dict[str, dict[Unknown, Unknown] | str | dict[str, str]], Literal[InvokeFrom.DEBUGGER], streaming=Literal[False]) [no-matching-overload]
+ERROR No matching overload found for function `core.app.apps.chat.app_generator.ChatAppGenerator.generate` called with arguments: (SimpleNamespace, SimpleNamespace, dict[str, dict[Unknown, Unknown] | str | dict[str, str]], Literal[InvokeFrom.DEBUGGER], streaming=Literal[False], session=MagicMock) [no-matching-overload]
    --> tests/unit_tests/core/app/apps/chat/test_app_generator_and_runner.py:110:40
 ERROR No matching overload found for function `core.app.apps.chat.app_generator.ChatAppGenerator.generate` called with arguments: (session=MagicMock, app_model=SimpleNamespace, user=SimpleNamespace, args=dict[str, dict[@_, @_] | str | dict[str, str]], invoke_from=Literal[InvokeFrom.SERVICE_API], streaming=Literal[False]) [no-matching-overload]
-   --> tests/uni\n\n... (truncated) ...

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 52.85% 53.10% +0.25%
Strict coverage 52.36% 52.60% +0.24%
Typed symbols 32,803 33,124 +321
Untyped symbols 29,539 29,539 0
Modules 2988 2988 0

@autofix-ci autofix-ci Bot requested a review from crazywoola as a code owner July 8, 2026 09:49
@github-actions github-actions Bot added the web This relates to changes on the web. label Jul 8, 2026
@41tair 41tair requested a review from GareArc as a code owner July 9, 2026 07:52

@cqjjjzr cqjjjzr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most issues I found fall into 3 buckets:

  1. Missing commit
  2. Mislabelling writing session as read-only session
  3. Long running session now holding locks against possibly dirty rows, affecting other writing threads

IMHO, for 1 and 2, the current lack of proper test against the eventual contract on DB state is to be blamed. For 3, I strongly suggest splitting large hunks of behavioral change code on long-running task into separate PRs (since they are the most hard to debug and risky since a lot of problems only surface on prod w/ concurrency and high load).

Comment thread api/commands/plugin.py
Comment thread api/controllers/console/datasets/datasets.py Outdated
Comment thread api/core/workflow/nodes/knowledge_index/knowledge_index_node.py
Comment thread api/tasks/document_indexing_task.py Outdated
Comment thread api/controllers/console/agent/roster.py Outdated
Comment thread api/controllers/console/datasets/datasets_document.py Outdated
Comment thread api/tasks/batch_create_segment_to_index_task.py Outdated
Comment thread api/tasks/batch_clean_document_task.py Outdated
Comment thread api/tasks/clean_document_task.py Outdated
Comment thread api/tasks/clean_notion_document_task.py Outdated
@github-actions github-actions Bot removed the web This relates to changes on the web. label Jul 11, 2026
@41tair 41tair requested a review from cqjjjzr July 11, 2026 03:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants