Skip to content

refactor(api): persist Agent App thoughts through explicit sessions - #45778

Open
eric7h wants to merge 6 commits into
langgenius:mainfrom
eric7h:refactor/agent-app-thought-explicit-session
Open

eric7h wants to merge 6 commits into
langgenius:mainfrom
eric7h:refactor/agent-app-thought-explicit-session

Conversation

@eric7h

@eric7h eric7h commented Nov 7, 2026

Copy link
Copy Markdown

Important

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

Summary

Related to #45584.

Agent App still persisted thought rows and message usage through Flask-SQLAlchemy's global db.session, including rollback() in stream error handlers. This PR moves those writes onto short-lived create_session() units so commit/rollback stay on the session that performed the work.

#45775 covers BaseAgentRunner. This slice is the Agent App recorder (_create_thought, _update_thought, trim_answer_suffix) and _persist_message_usage.

Unit tests now stub create_session to reuse the SQLite session, so the existing commit-failure coverage still observes the same session object.

Screenshots

N/A (backend session lifecycle)

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 verified the change and added or updated tests where meaningful regression risk justifies coverage.
  • I've updated the documentation accordingly.
  • I ran 🔧 Running ruff format, check with fixes, response contract lint, import linter, and dotenv-linter... (backend) and (frontend) to appease the lint gods
    EOF
    )

Drop Flask-SQLAlchemy global db.session from Agent App thought and usage writes. Short-lived create_session() units own commit/rollback, which is the remaining agent-thought slice of langgenius#45584.

Tests reuse the SQLite session through a create_session stub so existing commit-failure coverage still sees the same session object.
@eric7h
eric7h requested a review from QuantumGhost as a code owner November 7, 2026 06:44
@github-actions github-actions Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Nov 7, 2026
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-11-16 18:59:38.504350506 +0000
+++ /tmp/pyrefly_pr.txt	2026-11-16 18:59:21.500248972 +0000
@@ -172,44 +172,6 @@
   --> providers/vdb/vdb-tencent/tests/e2e_tests/conftest.py:95:33
 ERROR Object of class `ModuleType` has no attribute `VectorType` [missing-attribute]
   --> providers/vdb/vdb-tidb-vector/tests/unit_tests/src/dify_vdb_tidb_vector/test_tidb_vector.py:77:5
-ERROR Cannot find module `deepeval.metrics` [missing-import]
-   --> core/evaluation/frameworks/deepeval/deepeval_evaluator.py:259:5
-ERROR Cannot find module `deepeval.test_case` [missing-import]
-   --> core/evaluation/frameworks/deepeval/deepeval_evaluator.py:268:5
-ERROR Cannot find module `deepeval.models` [missing-import]
-  --> core/evaluation/frameworks/deepeval/deepeval_model_wrapper.py:16:1
-ERROR Class member `DifyDeepEvalModel.supports_structured_outputs` is marked as an override, but no parent class has a matching attribute [bad-override]
-  --> core/evaluation/frameworks/deepeval/deepeval_model_wrapper.py:94:9
-ERROR Class member `DifyDeepEvalModel.supports_temperature` is marked as an override, but no parent class has a matching attribute [bad-override]
-  --> core/evaluation/frameworks/deepeval/deepeval_model_wrapper.py:98:9
-ERROR Cannot find module `langchain_core.embeddings` [missing-import]
- --> core/evaluation/frameworks/ragas/ragas_embeddings_wrapper.py:4:1
-ERROR Class member `DifyEmbeddingsWrapper.aembed_query` is marked as an override, but no parent class has a matching attribute [bad-override]
-  --> core/evaluation/frameworks/ragas/ragas_embeddings_wrapper.py:83:15
-ERROR Class member `DifyEmbeddingsWrapper.aembed_documents` is marked as an override, but no parent class has a matching attribute [bad-override]
-  --> core/evaluation/frameworks/ragas/ragas_embeddings_wrapper.py:87:15
-ERROR Cannot find module `ragas` [missing-import]
-   --> core/evaluation/frameworks/ragas/ragas_evaluator.py:275:9
-ERROR Cannot find module `ragas.dataset_schema` [missing-import]
-   --> core/evaluation/frameworks/ragas/ragas_evaluator.py:276:9
-ERROR Cannot find module `ragas.run_config` [missing-import]
-   --> core/evaluation/frameworks/ragas/ragas_evaluator.py:277:9
-ERROR Cannot find module `ragas.dataset_schema` [missing-import]
-   --> core/evaluation/frameworks/ragas/ragas_evaluator.py:338:9
-ERROR Cannot find module `ragas.dataset_schema` [missing-import]
-   --> core/evaluation/frameworks/ragas/ragas_evaluator.py:415:5
-ERROR Cannot find module `ragas.messages` [missing-import]
-   --> core/evaluation/frameworks/ragas/ragas_evaluator.py:416:5
-ERROR Cannot find module `ragas.metrics` [missing-import]
-   --> core/evaluation/frameworks/ragas/ragas_evaluator.py:417:5
-ERROR Cannot find module `langchain_core.messages` [missing-import]
- --> core/evaluation/frameworks/ragas/ragas_model_wrapper.py:5:1
-ERROR Cannot find module `langchain_core.outputs` [missing-import]
- --> core/evaluation/frameworks/ragas/ragas_model_wrapper.py:6:1
-ERROR Cannot find module `langchain_core.prompt_values` [missing-import]
- --> core/evaluation/frameworks/ragas/ragas_model_wrapper.py:7:1
-ERROR Cannot find module `ragas.llms.base` [missing-import]
- --> core/evaluation/frameworks/ragas/ragas_model_wrapper.py:8:1
 ERROR Unpacked keyword argument `str` is not assignable to parameter `port` with type `int | None` in function `qdrant_client.qdrant_client.QdrantClient.__init__` [bad-argument-type]
   --> providers/vdb/vdb-tidb-on-qdrant/src/dify_vdb_tidb_on_qdrant/tidb_on_qdrant_vector.py:93:51
 ERROR Unpacked keyword argument `str` is not assignable to parameter `grpc_port` with type `int` in function `qdrant_client.qdrant_client.QdrantClient.__init__` [bad-argument-type]
@@ -571,119 +533,117 @@
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
    --> tests/e2e_tests/containers/services/test_app_service.py:151:37
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:188:36
+   --> tests/e2e_tests/containers/services/test_app_service.py:187:36
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:194:25
+   --> tests/e2e_tests/containers/services/test_app_service.py:192:68
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:205:37
+   --> tests/e2e_tests/containers/services/test_app_service.py:202:37
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:231:13
+   --> tests/e2e_tests/containers/services/test_app_service.py:227:13
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:237:13
+   --> tests/e2e_tests/containers/services/test_app_service.py:233:13
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:243:13
+   --> tests/e2e_tests/containers/services/test_app_service.py:239:13
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:261:25
+   --> tests/e2e_tests/containers/services/test_app_service.py:257:25
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:272:13
+   --> tests/e2e_tests/containers/services/test_app_service.py:268:13
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:285:13
+   --> tests/e2e_tests/containers/services/test_app_service.py:281:13
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:320:13
+   --> tests/e2e_tests/containers/services/test_app_service.py:315:13
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:326:13
+   --> tests/e2e_tests/containers/services/test_app_service.py:321:13
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:342:25
+   --> tests/e2e_tests/containers/services/test_app_service.py:337:25
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:353:25
+   --> tests/e2e_tests/containers/services/test_app_service.py:348:25
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:383:13
+   --> tests/e2e_tests/containers/services/test_app_service.py:378:13
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:389:13
+   --> tests/e2e_tests/containers/services/test_app_service.py:384:13
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:395:13
+   --> tests/e2e_tests/containers/services/test_app_service.py:390:13
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:401:13
+   --> tests/e2e_tests/containers/services/test_app_service.py:396:13
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:426:25
+   --> tests/e2e_tests/containers/services/test_app_service.py:421:25
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:439:13
+   --> tests/e2e_tests/containers/services/test_app_service.py:434:13
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:452:13
+   --> tests/e2e_tests/containers/services/test_app_service.py:447:13
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:506:32
+   --> tests/e2e_tests/containers/services/test_app_service.py:500:32
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:507:32
+   --> tests/e2e_tests/containers/services/test_app_service.py:501:32
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:511:25
+   --> tests/e2e_tests/containers/services/test_app_service.py:505:25
 ERROR Object of class `NoneType` has no attribute `items` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:513:20
+   --> tests/e2e_tests/containers/services/test_app_service.py:507:20
 ERROR Cannot index into `object` [bad-index]
-   --> tests/e2e_tests/containers/services/test_app_service.py:514:16
+   --> tests/e2e_tests/containers/services/test_app_service.py:508:16
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:518:25
+   --> tests/e2e_tests/containers/services/test_app_service.py:512:25
 ERROR Object of class `NoneType` has no attribute `items` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:520:20
+   --> tests/e2e_tests/containers/services/test_app_service.py:514:20
 ERROR Cannot index into `object` [bad-index]
-   --> tests/e2e_tests/containers/services/test_app_service.py:521:26
+   --> tests/e2e_tests/containers/services/test_app_service.py:515:26
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:526:13
+   --> tests/e2e_tests/containers/services/test_app_service.py:520:13
 ERROR Object of class `NoneType` has no attribute `items` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:530:20
+   --> tests/e2e_tests/containers/services/test_app_service.py:524:20
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:569:32
+   --> tests/e2e_tests/containers/services/test_app_service.py:562:32
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:578:32
+   --> tests/e2e_tests/containers/services/test_app_service.py:571:32
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:582:13
+   --> tests/e2e_tests/containers/services/test_app_service.py:575:13
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:625:38
+   --> tests/e2e_tests/containers/services/test_app_service.py:617:38
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:628:27
+   --> tests/e2e_tests/containers/services/test_app_service.py:626:72
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:634:38
+   --> tests/e2e_tests/containers/services/test_app_service.py:630:24
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:642:25
+   --> tests/e2e_tests/containers/services/test_app_service.py:644:72
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:648:67
-ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:681:38
+   --> tests/e2e_tests/containers/services/test_app_service.py:680:38
 ERROR Argument `dict[str, bool | str]` is not assignable to parameter `args` with type `AppService.ArgsDict` in function `services.app_service.AppService.update_app` [bad-argument-type]
-   --> tests/e2e_tests/containers/services/test_app_service.py:700:55
+   --> tests/e2e_tests/containers/services/test_app_service.py:699:55
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:737:13
+   --> tests/e2e_tests/containers/services/test_app_service.py:736:13
 ERROR Missing required key `max_active_requests` for TypedDict `ArgsDict` [bad-typed-dict-key]
-   --> tests/e2e_tests/containers/services/test_app_service.py:757:17
+   --> tests/e2e_tests/containers/services/test_app_service.py:756:17
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:792:13
+   --> tests/e2e_tests/containers/services/test_app_service.py:791:13
 ERROR Missing required key `max_active_requests` for TypedDict `ArgsDict` [bad-typed-dict-key]
-   --> tests/e2e_tests/containers/services/test_app_service.py:813:21
+   --> tests/e2e_tests/containers/services/test_app_service.py:812:21
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:856:38
+   --> tests/e2e_tests/containers/services/test_app_service.py:855:38
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:913:38
+   --> tests/e2e_tests/containers/services/test_app_service.py:912:38
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:926:70
+   --> tests/e2e_tests/containers/services/test_app_service.py:925:70
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:965:38
+   --> tests/e2e_tests/containers/services/test_app_service.py:964:38
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-   --> tests/e2e_tests/containers/services/test_app_service.py:986:70
+   --> tests/e2e_tests/containers/services/test_app_service.py:985:70
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-    --> tests/e2e_tests/containers/services/test_app_service.py:1055:13
+    --> tests/e2e_tests/containers/services/test_app_service.py:1053:13
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-    --> tests/e2e_tests/containers/services/test_app_service.py:1071:13
+    --> tests/e2e_tests/containers/services/test_app_service.py:1069:13
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-    --> tests/e2e_tests/containers/services/test_app_service.py:1087:13
+    --> tests/e2e_tests/containers/services/test_app_service.py:1085:13
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-    --> tests/e2e_tests/containers/services/test_app_service.py:1104:13
+    --> tests/e2e_tests/containers/services/test_app_service.py:1102:13
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-    --> tests/e2e_tests/containers/services/test_app_service.py:1121:25
+    --> tests/e2e_tests/containers/services/test_app_service.py:1119:25
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-    --> tests/e2e_tests/containers/services/test_app_service.py:1131:13
+    --> tests/e2e_tests/containers/services/test_app_service.py:1129:13
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-    --> tests/e2e_tests/containers/services/test_app_service.py:1143:13
+    --> tests/e2e_tests/containers/services/test_app_service.py:1141:13
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
-    --> tests/e2e_tests/containers/services/test_app_service.py:1154:25
+    --> tests/e2e_tests/containers/services/test_app_service.py:1152:25
 ERROR Argument `Literal['normal']` is not assignable to parameter `status` with type `ConversationStatus | SQLCoreOperations[ConversationStatus]` in function `models.model.Conversation.__init__` [bad-argument-type]
   --> tests/e2e_tests/containers/services/test_audio_service_db.py:50:16
 ERROR Argument `Literal['web-app']` is not assignable to parameter `invoke_from` with type `InvokeFrom | SQLCoreOperations[InvokeFrom | None] | None` in function `models.model.Conversation.__init__` [bad-argument-type]
@@ -1036,12 +996,30 @@
    --> tests/e2e_tests/containers/services/test_model_provider_service.py:147:24
 ERROR Argument `str` is not assignable to parameter `model_type` with type `ModelType | SQLCoreOperations[ModelType]` in function `models.provider.ProviderModelSetting.__init__` [bad-argument-type]
    --> tests/e2e_tests/containers/services/test_model_provider_service.py:184:24
+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/e2e_tests/containers/services/test_schedule_service.py:30: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/e2e_tests/containers/services/test_schedule_service.py:32:58
+ERROR Argument `SimpleNamespace` is not assignable to parameter `workflow` with type `Workflow` in function `events.event_handlers.sync_workflow_schedule_when_app_published.sync_schedule_from_workflow` [bad-argument-type]
+   --> tests/e2e_tests/containers/services/test_schedule_service.py:319:26
+ERROR Argument `SimpleNamespace` is not assignable to parameter `workflow` with type `Workflow` in function `events.event_handlers.sync_workflow_schedule_when_app_published.sync_schedule_from_workflow` [bad-argument-type]
+   --> tests/e2e_tests/containers/services/test_schedule_service.py:353:26
+ERROR Argument `SimpleNamespace` is not assignable to parameter `workflow` with type `Workflow` in function `events.event_handlers.sync_workflow_schedule_when_app_published.sync_schedule_from_workflow` [bad-argument-type]
+   --> tests/e2e_tests/containers/services/test_schedule_service.py:382:22
 ERROR Argument `Literal['chat']` is not assignable to parameter `mode` with type `AppMode | SQLCoreOperations[AppMode]` in function `models.model.App.__init__` [bad-argument-type]
   --> tests/e2e_tests/containers/services/test_webapp_auth_service.py:45:14
 ERROR Argument `Literal['emoji']` is not assignable to parameter `icon_type` with type `IconType | SQLCoreOperations[IconType | None] | None` in function `models.model.App.__init__` [bad-argument-type]
   --> tests/e2e_tests/containers/services/test_webapp_auth_service.py:46:19
-WARN Identity comparison `False is False` is always True [unnecessary-comparison]
-  --> tests/e2e_tests/containers/services/test_webapp_auth_service.py:79:35
+ERROR Argument `Literal['workflow']` is not assignable to parameter `mode` with type `AppMode | SQLCoreOperations[AppMode]` in function `models.model.App.__init__` [bad-argument-type]
+  --> tests/e2e_tests/containers/services/test_webhook_service.py:62:14
+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/e2e_tests/containers/services/test_webhook_service_relationships.py:69:72
+ERROR Argument `Literal['workflow']` is not assignable to parameter `mode` with type `AppMode | SQLCoreOperations[AppMode]` in function `models.model.App.__init__` [bad-argument-type]
+  --> tests/e2e_tests/containers/services/test_webhook_service_relationships.py:91:18
+ERROR Argument `Literal['emoji']` is not assignable to parameter `icon_type` with type `IconType | SQLCoreOperations[IconType | None] | None` in function `models.model.App.__init__` [bad-argument-type]
+  --> tests/e2e_tests/containers/services/test_webhook_service_relationships.py:92:23
+ERROR Class `WebhookServiceRelationshipFactory` has no class attribute `_read_cache` [missing-attribute]
+   --> tests/e2e_tests/containers/services/test_webhook_service_relationships.py:549:26
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
    --> tests/e2e_tests/containers/services/test_workflow_app_service.py:126:38
 ERROR Argument `Literal['app-run']` is not assignable to parameter `triggered_from` with type `SQLCoreOperations[WorkflowRunTriggeredFrom] | WorkflowRunTriggeredFrom` in function `models.workflow.WorkflowRun.__init__` [bad-argument-type]
@@ -1420,8 +1398,6 @@
     --> tests/e2e_tests/containers/tasks/test_clean_notion_document_task.py:1045:23
 ERROR Argument `Literal['indexing']` is not assignable to parameter `value` with type `IndexingStatus | SQLCoreOperations[IndexingStatus]` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
    --> tests/e2e_tests/containers/tasks/test_create_segment_to_index_task.py:473:36
-ERROR Expected 0 positional arguments, got 1 in function `core.db.session_factory.SessionFactory.create_session` [bad-argument-count]
-  --> tests/e2e_tests/containers/tasks/test_dataset_indexing_task.py:75:60
 ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
    --> tests/e2e_tests/containers/tasks/test_deal_dataset_vector_index_task.py:224:16
 ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
@@ -1622,6 +1598,12 @@
   --> tests/e2e_tests/containers/trigger/conftest.py:65:14
 ERROR Argument `Literal['emoji']` is not assignable to parameter `icon_type` with type `IconType | SQLCoreOperations[IconType | None] | None` in function `models.model.App.__init__` [bad-argument-type]
   --> tests/e2e_tests/containers/trigger/conftest.py:66:19
+ERROR Argument `str | None` is not assignable to parameter `workflow_id` with type `SQLCoreOperations[str] | str` in function `models.trigger.WorkflowTriggerLog.__init__` [bad-argument-type]
+   --> tests/e2e_tests/containers/trigger/test_trigger_e2e.py:208:25
+ERROR Argument `dict[str, str | dict[str, str | dict[str, str]]]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `core.trigger.debug.event_selectors.TriggerDebugEventPoller.__init__` [bad-argument-type]
+   --> tests/e2e_tests/containers/trigger/test_trigger_e2e.py:310:21
+ERROR Argument `dict[str, Any]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.schedule_service.ScheduleService.to_schedule_config` [bad-argument-type]
+   --> tests/e2e_tests/containers/trigger/test_trigger_e2e.py:611:49
 ERROR Class member `StaticRepo.get_form` overrides parent class `HumanInputFormRepository` in an inconsistent manner [bad-override]
    --> tests/e2e_tests/contracts/core/workflow/graph_engine/test_parallel_human_input_join_resume.py:137:9
 ERROR Argument `_TestFileReferenceFactory` is not assignable to parameter `file_reference_factory` with type `DifyFileReferenceFactory | None` in function `core.workflow.nodes.human_input.callback.DifyHITLCallback.__init__` [bad-argument-type]
@@ -1632,6 +1614,36 @@
    --> tests/e2e_tests/contracts/core/workflow/graph_engine/test_parallel_human_input_join_resume.py:221:32
 ERROR Argument `core.workflow.nodes.human_input.entities.HumanInputNodeData` is not assignable to parameter `data` with type `graphon.nodes.human_input.entities.HumanInputNodeData` in function `graphon.nodes.human_input.human_input_node.HumanInputNode.__init__` [bad-argument-type]
    --> tests/e2e_tests/contracts/core/workflow/graph_engine/test_parallel_human_input_join_resume.py:225:14
+ERROR Argument `SSRFProxy` is not assignable to parameter `http_client` with type `HttpClientProtocol` in function `graphon.nodes.http_request.executor.Executor.__init__` [bad-argument-type]
+  --> tests/e2e_tests/contracts/core/workflow/nodes/http_request/test_http_request_executor.py:64:21
+ERROR Argument `SSRFProxy` is not assignable to parameter `http_client` with type `HttpClientProtocol` in function `graphon.nodes.http_request.executor.Executor.__init__` [bad-argument-type]
+   --> tests/e2e_tests/contracts/core/workflow/nodes/http_request/test_http_request_executor.py:120:21
+ERROR Argument `SSRFProxy` is not assignable to parameter `http_client` with type `HttpClientProtocol` in function `graphon.nodes.http_request.executor.Executor.__init__` [bad-argument-type]
+   --> tests/e2e_tests/contracts/core/workflow/nodes/http_request/test_http_request_executor.py:178:21
+ERROR Argument `SSRFProxy` is not assignable to parameter `http_client` with type `HttpClientProtocol` in function `graphon.nodes.http_request.executor.Executor.__init__` [bad-argument-type]
+   --> tests/e2e_tests/contracts/core/workflow/nodes/http_request/test_http_request_executor.py:224:21
+ERROR Argument `SSRFProxy` is not assignable to parameter `http_client` with type `HttpClientProtocol` in function `graphon.nodes.http_request.executor.Executor.__init__` [bad-argument-type]
+   --> tests/e2e_tests/contracts/core/workflow/nodes/http_request/test_http_request_executor.py:271:21
+ERROR Argument `SSRFProxy` is not assignable to parameter `http_client` with type `HttpClientProtocol` in function `graphon.nodes.http_request.executor.Executor.__init__` [bad-argument-type]
+   --> tests/e2e_tests/contracts/core/workflow/nodes/http_request/test_http_request_executor.py:324:25
+ERROR Argument `SSRFProxy` is not assignable to parameter `http_client` with type `HttpClientProtocol` in function `graphon.nodes.http_request.executor.Executor.__init__` [bad-argument-type]
+   --> tests/e2e_tests/contracts/core/workflow/nodes/http_request/test_http_request_executor.py:361:25
+ERROR Argument `SSRFProxy` is not assignable to parameter `http_client` with type `HttpClientProtocol` in function `graphon.nodes.http_request.executor.Executor.__init__` [bad-argument-type]
+   --> tests/e2e_tests/contracts/core/workflow/nodes/http_request/test_http_request_executor.py:413:25
+ERROR Argument `SSRFProxy` is not assignable to parameter `http_client` with type `HttpClientProtocol` in function `graphon.nodes.http_request.executor.Executor.__init__` [bad-argument-type]
+   --> tests/e2e_tests/contracts/core/workflow/nodes/http_request/test_http_request_executor.py:440:25
+ERROR Argument `SSRFProxy` is not assignable to parameter `http_client` with type `HttpClientProtocol` in function `graphon.nodes.http_request.executor.Executor.__init__` [bad-argument-type]
+   --> tests/e2e_tests/contracts/core/workflow/nodes/http_request/test_http_request_executor.py:467:25
+ERROR Argument `SSRFProxy` is not assignable to parameter `http_client` with type `HttpClientProtocol` in function `graphon.nodes.http_request.executor.Executor.__init__` [bad-argument-type]
+   --> tests/e2e_tests/contracts/core/workflow/nodes/http_request/test_http_request_executor.py:494:25
+ERROR Argument `SSRFProxy` is not assignable to parameter `http_client` with type `HttpClientProtocol` in function `graphon.nodes.http_request.executor.Executor.__init__` [bad-argument-type]
+   --> tests/e2e_tests/contracts/core/workflow/nodes/http_request/test_http_request_executor.py:520:21
+ERROR Argument `SSRFProxy` is not assignable to parameter `http_client` with type `HttpClientProtocol` in function `graphon.nodes.http_request.executor.Executor.__init__` [bad-argument-type]
+   --> tests/e2e_tests/contracts/core/workflow/nodes/http_request/test_http_request_executor.py:570:21
+ERROR Argument `SSRFProxy` is not assignable to parameter `http_client` with type `HttpClientProtocol` in function `graphon.nodes.http_request.executor.Executor.__init__` [bad-argument-type]
+   --> tests/e2e_tests/contracts/core/workflow/nodes/http_request/test_http_request_executor.py:617:21
+ERROR Argument `SSRFProxy` is not assignable to parameter `http_client` with type `HttpClientProtocol` in function `graphon.nodes.http_request.executor.Executor.__init__` [bad-argument-type]
+   --> tests/e2e_tests/contracts/core/workflow/nodes/http_request/test_http_request_executor.py:658:21
 ERROR Cannot index into `object` [bad-index]
   --> tests/e2e_tests/contracts/core/workflow/nodes/http_request/test_http_request_node.py:32:15
 ERROR Cannot index into `object` [bad-index]
@@ -1658,8 +1670,6 @@
     --> tests/e2e_tests/contracts/core/workflow/nodes/llm/test_node.py:1863:32
 ERROR Missing argument `run_context` in function `core.app.llm.model_access.DifyModelFactory.__init__` [missing-argument]
     --> tests/e2e_tests/contracts/core/workflow/nodes/llm/test_node.py:1866:25
-ERROR Argument `list[None]` is not assignable to parameter `value` with type `Sequence[File]` in function `graphon.variables.segments.ArrayFileSegment.model_construct` [bad-argument-type]
-   --> tests/e2e_tests/contracts/core/workflow/nodes/test_document_extractor_node.py:124:50
 ERROR Object of class `NoneType` has no attribute `assert_called_once_with` [missing-attribute]
    --> tests/e2e_tests/contracts/core/workflow/nodes/test_document_extractor_node.py:217:9
 ERROR Object of class `NoneType` has no attribute `assert_called_once_with` [missing-attribute]
@@ -1672,12 +1682,12 @@
    --> tests/e2e_tests/contracts/core/workflow/nodes/test_if_else.py:388:19
 ERROR Argument `dict[str, list[dict[str, list[dict[str, list[str] | str]] | str]] | str]` is not assignable to parameter `node_data` with type `IfElseNodeData | dict[str, object]` in function `_build_if_else_node` [bad-argument-type]
    --> tests/e2e_tests/contracts/core/workflow/nodes/test_if_else.py:453:19
+ERROR `Literal['{invalid-json-schema']` is not assignable to attribute `json_schema` with type `dict[str, Any] | None` [bad-assignment]
+   --> tests/e2e_tests/contracts/core/workflow/nodes/test_start_node_json_object.py:209:28
 ERROR Argument `_StubToolRuntime` is not assignable to parameter `runtime` with type `ToolNodeRuntimeProtocol` in function `graphon.nodes.tool.tool_node.ToolNode.__init__` [bad-argument-type]
    --> tests/e2e_tests/contracts/core/workflow/nodes/tool/test_tool_node.py:112:17
 ERROR Argument `Iterator[ToolRuntimeMessage]` is not assignable to parameter `messages` with type `Generator[ToolRuntimeMessage]` in function `graphon.nodes.tool.tool_node.ToolNode._transform_message` [bad-argument-type]
    --> tests/e2e_tests/contracts/core/workflow/nodes/tool/test_tool_node.py:128:18
-ERROR Argument `list[ParagraphInputConfig]` is not assignable to parameter `inputs` with type `list[FormInputConfig]` in function `tests.helpers.unit.libs._human_input.support.FormService.create_form` [bad-argument-type]
-   --> tests/e2e_tests/contracts/libs/_human_input/test_form_service.py:311:34
 ERROR `-` is not supported between `None` and `datetime` [unsupported-operation]
   --> tests/e2e_tests/contracts/libs/_human_input/test_models.py:64:21
 ERROR `-` is not supported between `None` and `datetime` [unsupported-operation]
@@ -1798,6 +1808,10 @@
    --> tests/helpers/unit/core/workflow/nodes/code/code_node_spec.py:419:27
 ERROR `BaseNodeData` is not assignable to attribute `_node_data` with type `CodeNodeData` [bad-assignment]
    --> tests/helpers/unit/core/workflow/nodes/code/code_node_spec.py:435:27
+ERROR `dict[str, str | None]` is not assignable to dict key `site` with type `list[dict[str, Any]] | list[dict[str, str]] | str` [bad-assignment]
+   --> tests/helpers/unit/libs/_human_input/support.py:102:32
+ERROR `dict[str, str]` is not assignable to dict key `site` with type `list[FormInputConfig] | list[dict[str, Any]] | str` [bad-assignment]
+   --> tests/helpers/unit/libs/_human_input/support.py:217:34
 WARN No attribute `current_account_with_tenant` in module `controllers.console.datasets.datasets` [missing-attribute-patch-target]
    --> tests/helpers/unit/services/controller_api.py:333:20
 WARN No attribute `DatasetService` in module `controllers.console.datasets.datasets` [missing-attribute-patch-target]
@@ -1854,8 +1868,6 @@
    --> tests/helpers/unit/services/dataset_service_test_helpers.py:338:22
 ERROR Argument `Literal['completed']` is not assignable to parameter `status` with type `SQLCoreOperations[SegmentStatus] | SegmentStatus` in function `models.dataset.DocumentSegment.__init__` [bad-argument-type]
    --> tests/helpers/unit/services/dataset_service_test_helpers.py:372:16
-ERROR Argument `DataSource | object | None` is not assignable to parameter `data_source` with type `DataSource | Mapping[str, Any] | None` in function `services.knowledge.entities.knowledge_entities.KnowledgeConfig.__init__` [bad-argument-type]
-   --> tests/helpers/unit/services/dataset_service_test_helpers.py:409:21
 ERROR Argument `str` is not assignable to parameter `indexing_technique` with type `Literal['economy', 'high_quality']` in function `services.entities.knowledge_entities.rag_pipeline_entities.KnowledgeConfiguration.__init__` [bad-argument-type]
    --> tests/helpers/unit/services/dataset_service_test_helpers.py:460:28
 ERROR Cannot index into `list[Unknown]` [bad-index]
@@ -1982,38 +1994,108 @@
    --> tests/helpers/workflow/mock_nodes.py:755:52
 ERROR Cannot set item in `dict[str, str]` [unsupported-operation]
    --> tests/helpers/workflow/mock_nodes.py:757:52
+ERROR Argument `Sequence[type[EngineEvent]]` is not assignable to parameter `expected_sequence` with type `list[type[EngineEvent]]` in function `TableTestRunner._validate_event_sequence` [bad-argument-type]
+   --> tests/helpers/workflow/table_runner.py:336:21
+ERROR `graph` is uninitialized [unbound-name]
+   --> tests/helpers/workflow/table_runner.py:389:23
+ERROR `graph_runtime_state` is uninitialized [unbound-name]
+   --> tests/helpers/workflow/table_runner.py:390:37
 WARN `URLError` is already caught earlier in this `try` statement, so it never matches here [unreachable-except-clause]
    --> tests/pytest_dify.py:155:34
+ERROR Object of class `IExecutionContext` has no attribute `context_vars` [missing-attribute]
+   --> tests/unit_tests/context/test_execution_context.py:320:16
+ERROR Object of class `BaseModel` has no attribute `base_url` [missing-attribute]
+   --> tests/unit_tests/context/test_execution_context.py:341:16
+ERROR Object of class `BaseModel` has no attribute `base_url` [missing-attribute]
+   --> tests/unit_tests/context/test_execution_context.py:342:16
+ERROR Object of class `Flask` has no attribute `_get_current_object` [missing-attribute]
+  --> tests/unit_tests/context/test_flask_app_context.py:73:20
+ERROR Object of class `Flask` has no attribute `_get_current_object` [missing-attribute]
+   --> tests/unit_tests/context/test_flask_app_context.py:135:20
+ERROR Object of class `IExecutionContext` has no attribute `context_vars` [missing-attribute]
+   --> tests/unit_tests/context/test_flask_app_context.py:165:20
+ERROR Object of class `Flask` has no attribute `_get_current_object` [missing-attribute]
+   --> tests/unit_tests/context/test_flask_app_context.py:208:22
+ERROR Object of class `Flask` has no attribute `_get_current_object` [missing-attribute]
+   --> tests/unit_tests/context/test_flask_app_context.py:266:20
+ERROR Object of class `Flask` has no attribute `_get_current_object` [missing-attribute]
+   --> tests/unit_tests/context/test_flask_app_context.py:295:20
 ERROR Object of class `FromClause` has no attribute `create` [missing-attribute]
-   --> tests/unit_tests/controllers/console/app/test_app.py:174:13
+   --> tests/unit_tests/controllers/console/app/test_app.py:173:13
 ERROR Argument value `Literal[0]` violates Pydantic `ge` constraint `Literal[1]` for field `page` [bad-argument-type]
-   --> tests/unit_tests/controllers/console/app/test_app.py:666:55
+   --> tests/unit_tests/controllers/console/app/test_app.py:665:55
 ERROR Object of class `App` has no attribute `create_user_name` [missing-attribute]
-   --> tests/unit_tests/controllers/console/app/test_app.py:760:5
+   --> tests/unit_tests/controllers/console/app/test_app.py:759:5
 ERROR Object of class `App` has no attribute `permission_keys` [missing-attribute]
-   --> tests/unit_tests/controllers/console/app/test_app.py:762:5
+   --> tests/unit_tests/controllers/console/app/test_app.py:761:5
 ERROR Object of class `App` has no attribute `permission_keys` [missing-attribute]
-   --> tests/unit_tests/controllers/console/app/test_app.py:960:82
+   --> tests/unit_tests/controllers/console/app/test_app.py:959:82
 ERROR Object of class `App` has no attribute `permission_keys` [missing-attribute]
-   --> tests/unit_tests/controllers/console/app/test_app.py:991:9
+   --> tests/unit_tests/controllers/console/app/test_app.py:990:9
 ERROR Object of class `App` has no attribute `permission_keys` [missing-attribute]
-    --> tests/unit_tests/controllers/console/app/test_app.py:1004:37
+    --> tests/unit_tests/controllers/console/app/test_app.py:1003:37
 ERROR Object of class `App` has no attribute `permission_keys` [missing-attribute]
-    --> tests/unit_tests/controllers/console/app/test_app.py:1076:9
+    --> tests/unit_tests/controllers/console/app/test_app.py:1075:9
 ERROR `str` is not assignable to dict key `strategy` with type `bool | list[Unknown]` [bad-assignment]
-    --> tests/unit_tests/controllers/console/app/test_app.py:1114:38
-ERROR Missing argument `app_model` in function `controllers.console.app.workflow.EvaluationPublishedWorkflowApi.post` [missing-argument]
-    --> tests/unit_tests/controllers/console/app/test_workflow.py:1419:30
-ERROR Missing argument `app_model` in function `controllers.console.app.workflow.WorkflowKindConvertApi.post` [missing-argument]
-    --> tests/unit_tests/controllers/console/app/test_workflow.py:1419:30
+    --> tests/unit_tests/controllers/console/app/test_app.py:1113:38
+ERROR Argument `str | None` is not assignable to parameter `tenant_id` with type `SQLCoreOperations[str] | str` in function `models.model.App.__init__` [bad-argument-type]
+   --> tests/unit_tests/controllers/console/app/test_app_import.py:135:31
+ERROR Cannot index into `object` [bad-index]
+   --> tests/unit_tests/controllers/console/app/test_audio.py:341:16
+ERROR Cannot index into `object` [bad-index]
+   --> tests/unit_tests/controllers/console/app/test_audio.py:342:16
+ERROR Cannot index into `object` [bad-index]
+   --> tests/unit_tests/controllers/console/app/test_audio.py:343:16
+ERROR Cannot index into `object` [bad-index]
+   --> tests/unit_tests/controllers/console/app/test_audio.py:344:25
+ERROR Cannot index into `object` [bad-index]
+   --> tests/unit_tests/controllers/console/app/test_audio.py:357:21
+WARN Identity comparison `False is False` is always True [unnecessary-comparison]
+   --> tests/unit_tests/controllers/console/app/test_audio.py:437:31
+ERROR Object of class `FunctionType` has no attribute `__wrapped__` [missing-attribute]
+   --> tests/unit_tests/controllers/console/app/test_model_config.py:778:18
+ERROR Object of class `FunctionType` has no attribute `__wrapped__` [missing-attribute]
+   --> tests/unit_tests/controllers/console/app/test_model_config.py:779:29
+ERROR Missing argument `app_model` in function `controllers.console.app.model_config.ModelConfigResource.post` [missing-argument]
+   --> tests/unit_tests/controllers/console/app/test_model_config.py:790:15
+ERROR Unexpected keyword argument `current_tenant_id` in function `controllers.console.app.model_config.ModelConfigResource.post` [unexpected-keyword]
+   --> tests/unit_tests/controllers/console/app/test_model_config.py:792:13
+ERROR Unexpected keyword argument `current_user_id` in function `controllers.console.app.model_config.ModelConfigResource.post` [unexpected-keyword]
+   --> tests/unit_tests/controllers/console/app/test_model_config.py:793:13
+ERROR Unexpected keyword argument `app_id` in function `controllers.console.app.model_config.ModelConfigResource.post` [unexpected-keyword]
+   --> tests/unit_tests/controllers/console/app/test_model_config.py:794:13
+ERROR Argument `str | None` is not assignable to parameter `s` with type `bytearray | bytes | str` in function `json.loads` [bad-argument-type]
+   --> tests/unit_tests/controllers/console/app/test_model_config.py:891:36
 ERROR Missing argument `app_model` in function `controllers.console.app.workflow.WorkflowDraftHumanInputDeliveryTestApi.post` [missing-argument]
-    --> tests/unit_tests/controllers/console/app/test_workflow.py:1674:78
+    --> tests/unit_tests/controllers/console/app/test_workflow.py:1656:78
 ERROR Unexpected keyword argument `app_id` in function `controllers.console.app.workflow.WorkflowDraftHumanInputDeliveryTestApi.post` [unexpected-keyword]
-    --> tests/unit_tests/controllers/console/app/test_workflow.py:1674:79
+    --> tests/unit_tests/controllers/console/app/test_workflow.py:1656:79
 ERROR Missing argument `app_model` in function `controllers.console.app.workflow.AdvancedChatDraftHumanInputFormPreviewApi.post` [missing-argument]
-    --> tests/unit_tests/controllers/console/app/test_workflow.py:1688:81
+    --> tests/unit_tests/controllers/console/app/test_workflow.py:1670:81
 ERROR Unexpected keyword argument `app_id` in function `controllers.console.app.workflow.AdvancedChatDraftHumanInputFormPreviewApi.post` [unexpected-keyword]
-    --> tests/unit_tests/controllers/console/app/test_workflow.py:1688:82
+    --> tests/unit_tests/controllers/console/app/test_workflow.py:1670:82
+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]
+  --> tests/unit_tests/controllers/console/app/test_wraps.py:41:20
+ERROR Missing argument `app_model` in function `handler` [missing-argument]
+  --> tests/unit_tests/controllers/console/app/test_wraps.py:54:16
+ERROR Unexpected keyword argument `app_id` in function `handler` [unexpected-keyword]
+  --> tests/unit_tests/controllers/console/app/test_wraps.py:54:17
+ERROR Missing argument `app_model` in function `handler` [missing-argument]
+  --> tests/unit_tests/controllers/console/app/test_wraps.py:63:16
+ERROR Missing argument `app_model` in function `Handler.get` [missing-argument]
+  --> tests/unit_tests/controllers/console/app/test_wraps.py:86:29
+ERROR Unexpected keyword argument `app_id` in function `Handler.get` [unexpected-keyword]
+  --> tests/unit_tests/controllers/console/app/test_wraps.py:86:46
+ERROR Missing argument `app_model` in function `Handler.get` [missing-argument]
+   --> tests/unit_tests/controllers/console/app/test_wraps.py:124:26
+ERROR Unexpected keyword argument `app_id` in function `Handler.get` [unexpected-keyword]
+   --> tests/unit_tests/controllers/console/app/test_wraps.py:124:34
+ERROR Missing argument `app_model` in function `Handler.get` [missing-argument]
+   --> tests/unit_tests/controllers/console/app/test_wraps.py:126:29
+ERROR Unexpected keyword argument `app_id` in function `Handler.get` [unexpected-keyword]
+   --> tests/unit_tests/controllers/console/app/test_wraps.py:126:37
 ERROR Object of class `FunctionType` has no attribute `return_value` [missing-attribute]
   --> tests/unit_tests/controllers/console/auth/test_activate.py:71:9
 ERROR Object of class `FunctionType` has no attribute `assert_called_once_with` [missing-attribute]
@@ -2030,6 +2112,30 @@
    --> tests/unit_tests/controllers/console/auth/test_activate.py:226:9
 ERROR Object of class `FunctionType` has no attribute `assert_not_called` [missing-attribute]
    --> tests/unit_tests/controllers/console/auth/test_activate.py:253:9
+ERROR Object of class `FunctionType` has no attribute `return_value` [missing-attribute]
+   --> tests/unit_tests/controllers/console/auth/test_email_register.py:117:5
+ERROR Object of class `FunctionType` has no attribute `call_args` [missing-attribute]
+   --> tests/unit_tests/controllers/console/auth/test_email_register.py:128:12
+ERROR Object of class `FunctionType` has no attribute `side_effect` [missing-attribute]
+   --> tests/unit_tests/controllers/console/auth/test_email_register.py:150:5
+ERROR Object of class `FunctionType` has no attribute `return_value` [missing-attribute]
+   --> tests/unit_tests/controllers/console/auth/test_email_register.py:163:5
+ERROR Object of class `FunctionType` has no attribute `assert_called_once_with` [missing-attribute]
+   --> tests/unit_tests/controllers/console/auth/test_email_register.py:177:5
+ERROR Object of class `FunctionType` has no attribute `side_effect` [missing-attribute]
+   --> tests/unit_tests/controllers/console/auth/test_email_register.py:199:5
+ERROR Object of class `FunctionType` has no attribute `return_value` [missing-attribute]
+   --> tests/unit_tests/controllers/console/auth/test_email_register.py:212:5
+ERROR Object of class `FunctionType` has no attribute `call_args` [missing-attribute]
+   --> tests/unit_tests/controllers/console/auth/test_email_register.py:236:12
+ERROR Object of class `FunctionType` has no attribute `side_effect` [missing-attribute]
+   --> tests/unit_tests/controllers/console/auth/test_email_register.py:268:5
+ERROR Object of class `FromClause` has no attribute `create` [missing-attribute]
+  --> tests/unit_tests/controllers/console/datasets/rag_pipeline/test_rag_pipeline.py:83:9
+ERROR Unexpected keyword argument `created_at` in function `models.workflow.WorkflowNodeExecutionModel.__init__` [unexpected-keyword]
+   --> tests/unit_tests/controllers/console/datasets/rag_pipeline/test_rag_pipeline_workflow.py:876:9
+ERROR Argument `datetime | None` is not assignable to parameter `value` with type `SQLCoreOperations[datetime] | datetime` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
+   --> tests/unit_tests/controllers/console/datasets/rag_pipeline/test_rag_pipeline_workflow.py:924:27
 ERROR Unpacked keyword argument `int | str | Unknown` is not assignable to parameter `tenant_id` with type `SQLCoreOperations[str] | str` in function `models.dataset.Document.__init__` [bad-argument-type]
    --> tests/unit_tests/controllers/console/datasets/test_datasets_document.py:615:9
 ERROR Unpacked keyword argument `int | str | Unknown` is not assignable to parameter `dataset_id` with type `SQLCoreOperations[str] | str` in function `models.dataset.Document.__init__` [bad-argument-type]
@@ -2112,10 +2218,16 @@
    --> tests/unit_tests/controllers/console/datasets/test_datasets_document.py:640:30
 ERROR Argument `Literal['account']` is not assignable to parameter `created_by_role` with type `CreatorUserRole` in function `models.model.UploadFile.__init__` [bad-argument-type]
    --> tests/unit_tests/controllers/console/datasets/test_datasets_document.py:646:33
+ERROR Argument `RequestContext` is not assignable to parameter `object` with type `ExternalKnowledgeApiPayload` in function `list.append` [bad-argument-type]
+  --> tests/unit_tests/controllers/console/datasets/test_external.py:86:17
+ERROR Argument `UUID` is not assignable to parameter `object` with type `ExternalKnowledgeApiPayload` in function `list.append` [bad-argument-type]
+  --> tests/unit_tests/controllers/console/datasets/test_external.py:88:21
+ERROR Argument `SimpleNamespace` is not assignable to parameter `form` with type `Form` in function `controllers.console.human_input_form._jsonify_form_definition` [bad-argument-type]
+  --> tests/unit_tests/controllers/console/test_human_input_form.py:94:41
+ERROR Argument `SimpleNamespace` is not assignable to parameter `form` with type `Form` in function `controllers.console.human_input_form.ConsoleHumanInputFormApi._ensure_console_access` [bad-argument-type]
+   --> tests/unit_tests/controllers/console/test_human_input_form.py:105:57
 ERROR Type `Response` is not iterable [not-iterable]
-   --> tests/unit_tests/controllers/console/test_wraps.py:313:17
-ERROR `None` is not subscriptable [unsupported-operation]
-    --> tests/unit_tests/controllers/console/test_wraps.py:1030:16
+   --> tests/unit_tests/controllers/console/test_wraps.py:306:17
 ERROR Argument value `Literal[0]` violates Pydantic `ge` constraint `Literal[1]` for field `page` [bad-argument-type]
    --> tests/unit_tests/controllers/console/workspace/test_endpoint.py:235:47
 ERROR Missing argument `plugin_id` in function `controllers.console.workspace.endpoint.EndpointListForPluginQuery.__init__` [missing-argument]
@@ -2142,28 +2254,32 @@
    --> tests/unit_tests/controllers/console/workspace/test_endpoint.py:517:46
 ERROR Missing argument `endpoint_id` in function `controllers.console.workspace.endpoint.EndpointIdPayload.__init__` [missing-argument]
    --> tests/unit_tests/controllers/console/workspace/test_endpoint.py:561:46
-ERROR Argument `list[object]` is not assignable to parameter `parameters` with type `Iterable[Mapping[str, Any] | WorkflowToolParameterConfiguration]` in function `controllers.console.workspace.tool_providers.WorkflowToolCreatePayload.__init__` [bad-argument-type]
-   --> tests/unit_tests/controllers/console/workspace/test_tool_providers.py:606:62
+ERROR `in` is not supported between `Literal['knowledge-retrieval']` and `object` [not-iterable]
+   --> tests/unit_tests/controllers/console/workspace/test_snippets.py:235:12
 ERROR Argument `Literal['file-id']` is not assignable to parameter `file_id` with type `UUID` in function `controllers.files.upload_file_delivery.ImagePreviewApi.get` [bad-argument-type]
-   --> tests/unit_tests/controllers/files/test_upload_file_delivery.py:101:53
+  --> tests/unit_tests/controllers/files/test_upload_file_delivery.py:47:53
 ERROR Argument `Literal['file-id']` is not assignable to parameter `file_id` with type `UUID` in function `controllers.files.upload_file_delivery.ImagePreviewApi.get` [bad-argument-type]
-   --> tests/unit_tests/controllers/files/test_upload_file_delivery.py:122:42
+  --> tests/unit_tests/controllers/files/test_upload_file_delivery.py:68:42
 ERROR Argument `Literal['file-id']` is not assignable to parameter `file_id` with type `UUID` in function `controllers.files.upload_file_delivery.ImagePreviewApi.get` [bad-argument-type]
-   --> tests/unit_tests/controllers/files/test_upload_file_delivery.py:130:42
+  --> tests/unit_tests/controllers/files/test_upload_file_delivery.py:76:42
 ERROR Argument `Literal['file-id']` is not assignable to parameter `file_id` with type `UUID` in function `controllers.files.upload_file_delivery.ImagePreviewApi.get` [bad-argument-type]
-   --> tests/unit_tests/controllers/files/test_upload_file_delivery.py:136:42
+  --> tests/unit_tests/controllers/files/test_upload_file_delivery.py:82:42
+ERROR Argument `Literal['file-id']` is not assignable to parameter `file_id` with type `UUID` in function `controllers.files.upload_file_delivery.FilePreviewApi.get` [bad-argument-type]
+   --> tests/unit_tests/controllers/files/test_upload_file_delivery.py:100:52
 ERROR Argument `Literal['file-id']` is not assignable to parameter `file_id` with type `UUID` in function `controllers.files.upload_file_delivery.FilePreviewApi.get` [bad-argument-type]
-   --> tests/unit_tests/controllers/files/test_upload_file_delivery.py:168:52
+   --> tests/unit_tests/controllers/files/test_upload_file_delivery.py:121:52
 ERROR Argument `Literal['file-id']` is not assignable to parameter `file_id` with type `UUID` in function `controllers.files.upload_file_delivery.FilePreviewApi.get` [bad-argument-type]
-   --> tests/unit_tests/controllers/files/test_upload_file_delivery.py:179:52
+   --> tests/unit_tests/controllers/files/test_upload_file_delivery.py:132:52
 ERROR Argument `Literal['file-id']` is not assignable to parameter `file_id` with type `UUID` in function `controllers.files.upload_file_delivery.FilePreviewApi.get` [bad-argument-type]
-   --> tests/unit_tests/controllers/files/test_upload_file_delivery.py:222:52
+   --> tests/unit_tests/controllers/files/test_upload_file_delivery.py:155:52
 ERROR Argument `Literal['file-id']` is not assignable to parameter `file_id` with type `UUID` in function `controllers.files.upload_file_delivery.FilePreviewApi.get` [bad-argument-type]
-   --> tests/unit_tests/controllers/files/test_upload_file_delivery.py:237:52
+   --> tests/unit_tests/controllers/files/test_upload_file_delivery.py:171:52
 ERROR Argument `Literal['file-id']` is not assignable to parameter `file_id` with type `UUID` in function `controllers.files.upload_file_delivery.FilePreviewApi.get` [bad-argument-type]
-   --> tests/unit_tests/controllers/files/test_upload_file_delivery.py:252:41
+   --> tests/unit_tests/controllers/files/test_upload_file_delivery.py:186:52
 ERROR Argument `Literal['file-id']` is not assignable to parameter `file_id` with type `UUID` in function `controllers.files.upload_file_delivery.FilePreviewApi.get` [bad-argument-type]
-   --> tests/unit_tests/controllers/files/test_upload_file_delivery.py:258:41
+   --> tests/unit_tests/controllers/files/test_upload_file_delivery.py:201:41
+ERROR Argument `Literal['file-id']` is not assignable to parameter `file_id` with type `UUID` in function `controllers.files.upload_file_delivery.FilePreviewApi.get` [bad-argument-type]
+   --> tests/unit_tests/controllers/files/test_upload_file_delivery.py:207:41
 ERROR Missing argument `tenant_model` in function `protected_view` [missing-argument]
    --> tests/unit_tests/controllers/inner_api/plugin/test_wraps.py:292:40
 ERROR Missing argument `user_model` in function `protected_view` [missing-argument]
@@ -2201,17 +2317,53 @@
 ERROR Object of class `FromClause` has no attribute `create` [missing-attribute]
    --> tests/unit_tests/controllers/mcp/test_mcp.py:168:17
 ERROR Object of class `FunctionType` has no attribute `__handler__` [missing-attribute]
-   --> tests/unit_tests/controllers/openapi/test_human_input_form.py:125:20
+   --> tests/unit_tests/controllers/openapi/test_app_run.py:192:20
+ERROR Object of class `FunctionType` has no attribute `__handler__` [missing-attribute]
+   --> tests/unit_tests/controllers/openapi/test_app_run.py:195:17
+ERROR Object of class `Resource` has no attribute `post` [missing-attribute]
+   --> tests/unit_tests/controllers/openapi/test_app_run.py:254:20
+ERROR Object of class `Resource` has no attribute `post` [missing-attribute]
+   --> tests/unit_tests/controllers/openapi/test_app_run.py:269:13
+ERROR Object of class `Resource` has no attribute `post` [missing-attribute]
+   --> tests/unit_tests/controllers/openapi/test_app_run.py:302:9
+ERROR Object of class `Resource` has no attribute `post` [missing-attribute]
+   --> tests/unit_tests/controllers/openapi/test_app_run.py:325:20
+ERROR Object of class `Resource` has no attribute `post` [missing-attribute]
+   --> tests/unit_tests/controllers/openapi/test_app_run.py:343:20
+ERROR Object of class `FunctionType` has no attribute `__handler__` [missing-attribute]
+   --> tests/unit_tests/controllers/openapi/test_human_input_form.py:126:20
+ERROR Object of class `FunctionType` has no attribute `__handler__` [missing-attribute]
+   --> tests/unit_tests/controllers/openapi/test_human_input_form.py:145:17
+ERROR Object of class `FunctionType` has no attribute `__handler__` [missing-attribute]
+   --> tests/unit_tests/controllers/openapi/test_human_input_form.py:158:17
+ERROR Object of class `FunctionType` has no attribute `__handler__` [missing-attribute]
+   --> tests/unit_tests/controllers/openapi/test_human_input_form.py:176:22
+ERROR Object of class `FunctionType` has no attribute `__handler__` [missing-attribute]
+   --> tests/unit_tests/controllers/openapi/test_human_input_form.py:203:22
+ERROR Object of class `FunctionType` has no attribute `__handler__` [missing-attribute]
+   --> tests/unit_tests/controllers/openapi/test_human_input_form.py:229:20
+ERROR Object of class `FunctionType` has no attribute `view_class` [missing-attribute]
+  --> tests/unit_tests/controllers/openapi/test_oauth_device.py:91:16
+ERROR Object of class `FunctionType` has no attribute `view_class` [missing-attribute]
+  --> tests/unit_tests/controllers/openapi/test_oauth_device.py:96:16
+ERROR `in` is not supported between `Literal['POST']` and `None` [not-iterable]
+   --> tests/unit_tests/controllers/openapi/test_oauth_device.py:102:16
+ERROR `in` is not supported between `Literal['POST']` and `None` [not-iterable]
+   --> tests/unit_tests/controllers/openapi/test_oauth_device.py:103:16
+ERROR Object of class `FunctionType` has no attribute `__handler__` [missing-attribute]
+   --> tests/unit_tests/controllers/openapi/test_workflow_events.py:134:17
 ERROR Object of class `FunctionType` has no attribute `__handler__` [missing-attribute]
-   --> tests/unit_tests/controllers/openapi/test_human_input_form.py:144:17
+   --> tests/unit_tests/controllers/openapi/test_workflow_events.py:153:17
 ERROR Object of class `FunctionType` has no attribute `__handler__` [missing-attribute]
-   --> tests/unit_tests/controllers/openapi/test_human_input_form.py:157:17
+   --> tests/unit_tests/controllers/openapi/test_workflow_events.py:167:17
 ERROR Object of class `FunctionType` has no attribute `__handler__` [missing-attribute]
-   --> tests/unit_tests/controllers/openapi/test_human_input_form.py:175:22
+   --> tests/unit_tests/controllers/openapi/test_workflow_events.py:182:20
 ERROR Object of class `FunctionType` has no attribute `__handler__` [missing-attribute]
-   --> tests/unit_tests/controllers/openapi/test_human_input_form.py:202:22
+   --> tests/unit_tests/controllers/openapi/test_workflow_events.py:224:20
 ERROR Object of class `FunctionType` has no attribute `__handler__` [missing-attribute]
-   --> tests/unit_tests/controllers/openapi/test_human_input_form.py:228:20
+   --> tests/unit_tests/controllers/openapi/test_workflow_events.py:254:20
+ERROR Object of class `FunctionType` has no attribute `__handler__` [missing-attribute]
+   --> tests/unit_tests/controllers/openapi/test_workflow_events.py:273:20
 ERROR Object of class `FunctionType` has no attribute `__handler__` [missing-attribute]
    --> tests/unit_tests/controllers/openapi/test_workspaces.py:242:14
 ERROR Object of class `FunctionType` has no attribute `__handler__` [missing-attribute]
@@ -2232,6 +2384,28 @@
    --> tests/unit_tests/controllers/openapi/test_workspaces.py:550:14
 ERROR Object of class `FunctionType` has no attribute `__handler__` [missing-attribute]
    --> tests/unit_tests/controllers/openapi/test_workspaces.py:664:9
+ERROR Cannot index into `Response` [bad-index]
+   --> tests/unit_tests/controllers/service_api/app/test_audio.py:205:16
+ERROR `None` is not subscriptable [unsupported-operation]
+   --> tests/unit_tests/controllers/service_api/app/test_audio.py:205:16
+ERROR Argument `list[dict[str, Any]] | None` is not assignable to parameter `obj` with type `Sized` in function `len` [bad-argument-type]
+   --> tests/unit_tests/controllers/service_api/app/test_completion.py:258:24
+ERROR Class member `_FakePauseEntity.get_pause_reasons` is marked as an override, but no parent class has a matching attribute [bad-override]
+   --> tests/unit_tests/controllers/service_api/app/test_workflow_events.py:274:9
+ERROR Argument `Literal['app-run']` is not assignable to parameter `triggered_from` with type `SQLCoreOperations[WorkflowRunTriggeredFrom] | WorkflowRunTriggeredFrom` in function `models.workflow.WorkflowRun.__init__` [bad-argument-type]
+   --> tests/unit_tests/controllers/service_api/app/test_workflow_events.py:285:24
+ERROR Argument `SimpleNamespace` is not assignable to parameter `queue_manager` with type `AppQueueManager` in function `core.app.apps.advanced_chat.generate_task_pipeline.AdvancedChatAppGenerateTaskPipeline.__init__` [bad-argument-type]
+   --> tests/unit_tests/controllers/service_api/app/test_workflow_events.py:532:27
+WARN `datetime.datetime.utcnow` is deprecated [deprecated]
+   --> tests/unit_tests/controllers/service_api/app/test_workflow_events.py:537:28
+ERROR Argument `(**kwargs: Unknown) -> None` is not assignable to parameter `draft_var_saver_factory` with type `DraftVariableSaverFactory` in function `core.app.apps.advanced_chat.generate_task_pipeline.AdvancedChatAppGenerateTaskPipeline.__init__` [bad-argument-type]
+   --> tests/unit_tests/controllers/service_api/app/test_workflow_events.py:544:37
+ERROR Argument `SimpleNamespace` is not assignable to parameter `queue_manager` with type `AppQueueManager` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline.__init__` [bad-argument-type]
+   --> tests/unit_tests/controllers/service_api/app/test_workflow_events.py:624:27
+ERROR Argument `(**kwargs: Unknown) -> None` is not assignable to parameter `draft_var_saver_factory` with type `DraftVariableSaverFactory` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline.__init__` [bad-argument-type]
+   --> tests/unit_tests/controllers/service_api/app/test_workflow_events.py:627:37
+ERROR Argument `SimpleNamespace` is not assignable to parameter `graph_runtime_state` with type `RuntimeState` in function `core.app.apps.common.workflow_response_converter.WorkflowResponseConverter.workflow_pause_to_stream_response` [bad-argument-type]
+   --> tests/unit_tests/controllers/service_api/app/test_workflow_events.py:717:33
 ERROR Argument `str` is not assignable to parameter `dataset_id` with type `UUID` in function `controllers.service_api.dataset.rag_pipeline.rag_pipeline_workflow.DatasourcePluginsApi.get` [bad-argument-type]
    --> tests/unit_tests/controllers/service_api/dataset/rag_pipeline/test_rag_pipeline_workflow.py:458:76
 ERROR Argument `str` is not assignable to parameter `dataset_id` with type `UUID` in function `controllers.service_api.dataset.rag_pipeline.rag_pipeline_workflow.DatasourcePluginsApi.get` [bad-argument-type]
@@ -2252,12 +2426,8 @@
    --> tests/unit_tests/controllers/service_api/dataset/rag_pipeline/test_rag_pipeline_workflow.py:676:21
 ERROR Object of class `FunctionType` has no attribute `__wrapped__` [missing-attribute]
    --> tests/unit_tests/controllers/service_api/dataset/rag_pipeline/test_rag_pipeline_workflow.py:702:21
-ERROR Object of class `FunctionType` has no attribute `__wrapped__` [missing-attribute]
-   --> tests/unit_tests/controllers/service_api/dataset/rag_pipeline/test_rag_pipeline_workflow.py:757:21
-ERROR Object of class `Exception` has no attribute `code` [missing-attribute]
-   --> tests/unit_tests/controllers/service_api/dataset/rag_pipeline/test_rag_pipeline_workflow.py:760:24
 ERROR Argument `None` is not assignable to parameter `value` with type `SQLCoreOperations[datetime] | datetime` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
-   --> tests/unit_tests/controllers/service_api/dataset/rag_pipeline/test_rag_pipeline_workflow.py:924:34
+   --> tests/unit_tests/controllers/service_api/dataset/rag_pipeline/test_rag_pipeline_workflow.py:868:34
 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:144:17
 ERROR No matching overload found for function `typing.MutableMapping.update` called with arguments: (dict[str, object]) [no-matching-overload]
@@ -2360,10 +2530,6 @@
    --> tests/unit_tests/controllers/service_api/dataset/test_segment.py:171:25
 ERROR Argument `str` is not assignable to parameter `doc_form` with type `IndexStructureType | SQLCoreOperations[IndexStructureType]` in function `models.dataset.Document.__init__` [bad-argument-type]
    --> tests/unit_tests/controllers/service_api/dataset/test_segment.py:173:18
-ERROR Argument value `Literal[0]` violates Pydantic `ge` constraint `Literal[1]` for field `limit` [bad-argument-type]
-   --> tests/unit_tests/controllers/service_api/dataset/test_segment.py:313:58
-ERROR Argument value `Literal[0]` violates Pydantic `ge` constraint `Literal[1]` for field `page` [bad-argument-type]
-   --> tests/unit_tests/controllers/service_api/dataset/test_segment.py:318:57
 ERROR Missing argument `mutations` in function `services.knowledge.dataset_service.SegmentService.multi_create_segment` [missing-argument]
    --> tests/unit_tests/controllers/service_api/dataset/test_segment.py:473:53
 ERROR Missing argument `mutations` in function `services.knowledge.dataset_service.SegmentService.delete_segment` [missing-argument]
@@ -2530,6 +2696,18 @@
    --> tests/unit_tests/controllers/service_api/test_wraps.py:961:16
 ERROR Object of class `NoneType` has no attribute `la\n\n... (truncated) ...

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 86.65% 84.60% -2.05%
Strict coverage 86.31% 84.26% -2.05%
Typed symbols 93,821 88,884 -4,937
Untyped symbols 14,511 16,248 +1,737
Modules 4599 4443 -156

@codecov

codecov Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 1.72414% with 57 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.04%. Comparing base (f73b180) to head (a84e461).
⚠️ Report is 325 commits behind head on main.

Files with missing lines Patch % Lines
api/core/app/apps/agent_app/app_runner.py 1.72% 57 Missing ⚠️

❌ Your project check has failed because the head coverage (77.74%) is below the adjusted base coverage (88.81%). You can increase the head coverage or adjust the Removed Code Behavior.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #45778      +/-   ##
==========================================
- Coverage   90.01%   83.04%   -6.98%     
==========================================
  Files        6265     6212      -53     
  Lines      391789   382168    -9621     
  Branches    78435    77897     -538     
==========================================
- Hits       352679   317366   -35313     
- Misses      33020    59135   +26115     
+ Partials     6090     5667     -423     
Flag Coverage Δ
api 77.74% <1.72%> (-12.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Rewrite test_partial_usage_persistence_rolls_back_database_error to mock
create_session (db was removed) and assert rollback via session-context
exit. Cover trim/update early-return paths and commit-failure rollback so
the explicit-session patch is exercised.
@eric7h

eric7h commented Nov 9, 2026

Copy link
Copy Markdown
Author

Fixed the broken unit test left over from the db → create_session migration: test_partial_usage_persistence_rolls_back_database_error now mocks create_session and asserts rollback on session-context exit (matching SQLAlchemy Session.__exit__). Also added coverage for trim/update early-return paths and commit-failure rollback. Local: test_app_runner.py 46 passed; ruff clean.

@asukaminato0721 asukaminato0721 self-assigned this Nov 16, 2026

@asukaminato0721 asukaminato0721 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.

3 inline suggestions at a84e4611b7, each from a rule learned from earlier reviews in this repository. Reply on a comment if it is wrong.

dify-codereview

sqlite_session.rollback()
raise

monkeypatch.setattr(app_runner_module, "create_session", reuse_session)

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.

Rather than patching this in the test, change the production code to take the dependency as a parameter (pass the session / account / service in), so the test hands in a real one and needs no patch.

dify-codereview · tests-real-dependencies (inject-dependency) Learned from an earlier review. Reply here if this is wrong.

metadata = json.loads(message.message_metadata) if message.message_metadata else {}
except (json.JSONDecodeError, TypeError):
metadata = {}
if not isinstance(metadata, dict):

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.

Parse, don't validate (https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/): model this data once at the boundary as a pydantic model / dataclass / TypedDict (Model.model_validate(raw)), and pass the typed value on, instead of passing dicts around and re-checking keys and types where they are used. In a test, don't build this as an ad hoc dict[str, object]: define the shape (TypedDict / model) in the production code and import it here.

dify-codereview · parse-dont-validate Learned from an earlier review. Reply here if this is wrong.

@asukaminato0721 asukaminato0721 added the waiting-for-author dify-codereview: the author has suggestions, a conflict, failing CI or unresolved threads to address label Nov 16, 2026
asukaminato0721

This comment was marked as outdated.

@asukaminato0721 asukaminato0721 added waiting-for-author dify-codereview: the author has suggestions, a conflict, failing CI or unresolved threads to address and removed waiting-for-author dify-codereview: the author has suggestions, a conflict, failing CI or unresolved threads to address labels Nov 16, 2026
The no-new-session-mock guard failed Style Check on the
create_session rollback tests. Keep the commit/rollback
assertions with a recording session double instead.
@eric7h

eric7h commented Nov 17, 2026

Copy link
Copy Markdown
Author

Thanks for the flag — Style Check failed on the no-new-session-mock guard at api/tests/unit_tests/core/app/apps/agent_app/test_app_runner.py:1577 after the create_session migration (session = MagicMock() in the commit-failure coverage).

I replaced the MagicMock session assignments in the two usage-persistence rollback tests with a small recording session double, so the same commit/rollback assertions remain without a net-new session mock. Locally, check_no_new_session_mock.py is clean against the PR base, and test_app_runner.py is 46 passed.

Pushed as 105aeebb. I'll watch the new CI run.

Separately, API Unit Tests shard 2 failed on tests/unit_tests/services/human_input_v2/test_message_template_test_service.py::test_email_renders_and_sends_only_to_editor_with_a_real_test_form (HumanInputFormError: not_found). That file is outside this PR's two-file diff; I'll check whether it recurs after this push.

@asukaminato0721 asukaminato0721 added waiting-for-author dify-codereview: the author has suggestions, a conflict, failing CI or unresolved threads to address and removed waiting-for-author dify-codereview: the author has suggestions, a conflict, failing CI or unresolved threads to address labels Nov 17, 2026
asukaminato0721

This comment was marked as outdated.

@asukaminato0721 asukaminato0721 added waiting-for-author dify-codereview: the author has suggestions, a conflict, failing CI or unresolved threads to address and removed waiting-for-author dify-codereview: the author has suggestions, a conflict, failing CI or unresolved threads to address labels Nov 27, 2026
Resolve Agent App thought-persistence conflicts by keeping current main
behavior and re-applying the create_session() migration, including the
new _restore_tool_identities path.
@eric7h

eric7h commented Nov 27, 2026

Copy link
Copy Markdown
Author

Thanks for the review — the branch had fallen behind and could not be merged cleanly.\n\nI've merged the latest into this branch (ordinary merge commit, no rebase) and resolved the conflicts in and . Current behavior is kept (, tool activity / changed detection, , ), and the migration is re-applied, including the new path so it no longer uses the Flask-SQLAlchemy global .\n\nLocally, / are clean on those two files, passes, and is 71 passed.\n\nThe PR should now be conflict-free. Happy to adjust if anything still looks off.\n

@asukaminato0721 asukaminato0721 added waiting-for-author dify-codereview: the author has suggestions, a conflict, failing CI or unresolved threads to address and removed waiting-for-author dify-codereview: the author has suggestions, a conflict, failing CI or unresolved threads to address labels Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files. waiting-for-author dify-codereview: the author has suggestions, a conflict, failing CI or unresolved threads to address

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants