Repository navigation
test: use sqlite_session for tool file lookups in message transformer tests - #45000
Conversation
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-10-29 06:19:33.453177925 +0000
+++ /tmp/pyrefly_pr.txt 2026-10-29 06:19:23.265081647 +0000
@@ -636,6 +636,16 @@
--> tests/e2e_tests/containers/services/test_conversation_service.py:155:20
ERROR Argument `Literal[core.app.entities.app_invoke_entities.InvokeFrom.WEB_APP]` is not assignable to parameter `invoke_from` with type `models.enums.InvokeFrom | SQLCoreOperations[models.enums.InvokeFrom | None] | None` in function `models.model.Message.__init__` [bad-argument-type]
--> tests/e2e_tests/containers/services/test_conversation_service.py:156:25
+ERROR Argument `Literal['owner']` is not assignable to parameter `role` with type `SQLCoreOperations[TenantAccountRole] | TenantAccountRole` in function `models.account.TenantAccountJoin.__init__` [bad-argument-type]
+ --> tests/e2e_tests/containers/services/test_conversation_service_variables.py:45:18
+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_conversation_service_variables.py:55: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_conversation_service_variables.py:56:23
+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_conversation_service_variables.py:113:20
+ERROR Argument `Literal['debugger', 'explore', 'openapi', 'published', 'service-api', 'trigger', 'validation', '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]
+ --> tests/e2e_tests/containers/services/test_conversation_service_variables.py:114:25
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_dataset_permission_service.py:39: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]
@@ -2483,9 +2493,9 @@
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:256:24
ERROR Argument value `Literal[0]` violates Pydantic `ge` constraint `Literal[1]` for field `limit` [bad-argument-type]
- --> tests/unit_tests/controllers/service_api/app/test_conversation.py:70:39
+ --> tests/unit_tests/controllers/service_api/app/test_conversation.py:125:39
ERROR Argument value `Literal[101]` violates Pydantic `le` constraint `Literal[100]` for field `limit` [bad-argument-type]
- --> tests/unit_tests/controllers/service_api/app/test_conversation.py:75:39
+ --> tests/unit_tests/controllers/service_api/app/test_conversation.py:130:39
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:283: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]
@@ -3428,6 +3438,14 @@
--> tests/unit_tests/core/app/apps/chat/test_app_generator.py:491:28
ERROR Argument `DummyQueueManager` is not assignable to parameter `queue_manager` with type `AppQueueManager` in function `core.app.apps.chat.app_runner.ChatAppRunner.run` [bad-argument-type]
--> tests/unit_tests/core/app/apps/chat/test_app_generator.py:491:49
+ERROR Cannot index into `str` [bad-index]
+ --> tests/unit_tests/core/app/apps/chat/test_generate_response_converter.py:60:16
+ERROR Cannot index into `str` [bad-index]
+ --> tests/unit_tests/core/app/apps/chat/test_generate_response_converter.py:61:16
+ERROR Cannot index into `str` [bad-index]
+ --> tests/unit_tests/core/app/apps/chat/test_generate_response_converter.py:65:16
+ERROR `SimpleNamespace` is not assignable to attribute `_base_task_pipeline` with type `BasedGenerateTaskPipeline[Unknown]` [bad-assignment]
+ --> tests/unit_tests/core/app/apps/common/test_graph_runtime_state_support.py:20:36
ERROR Object of class `NoneType` has no attribute `data` [missing-attribute]
--> tests/unit_tests/core/app/apps/common/test_workflow_response_converter.py:1175:20
ERROR Class member `_RecordingWorkflowAppRunner._publish_event` overrides a member in a parent class but is missing an `@override` decorator [missing-override-decorator]
@@ -3640,6 +3658,8 @@
--> tests/unit_tests/core/app/apps/test_workflow_app_runner.py:1073:29
ERROR Generator function should return `Generator` [bad-return]
--> tests/unit_tests/core/app/apps/workflow/test_active_workflow_tasks.py:15:29
+ERROR Cannot set item in `object` [unsupported-operation]
+ --> tests/unit_tests/core/app/apps/workflow/test_app_config_manager.py:47:17
ERROR Argument `tuple[Literal['layer']]` is not assignable to parameter `graph_engine_layers` with type `Sequence[Layer]` in function `core.app.apps.workflow.app_generator.WorkflowAppGenerator.resume` [bad-argument-type]
--> tests/unit_tests/core/app/apps/workflow/test_app_generator.py:398:33
ERROR Argument `tuple[Literal['base-layer']]` is not assignable to parameter `graph_engine_layers` with type `Sequence[Layer]` in function `core.app.apps.workflow.app_generator.WorkflowAppGenerator._generate` [bad-argument-type]
@@ -5661,17 +5681,17 @@
ERROR Argument `dict[@_, @_]` is not assignable to parameter `headers` with type `HTTPHeaders` in function `botocore.awsrequest.AWSResponse.__init__` [bad-argument-type]
--> tests/unit_tests/libs/test_archive_storage.py:160:50
ERROR `dict[str, str]` is not assignable to attribute `description` with type `str | None` [bad-assignment]
- --> tests/unit_tests/libs/test_external_api.py:84:29
+ --> tests/unit_tests/libs/test_external_api.py:83:29
ERROR Argument `_PassthroughFormatter` is not assignable to parameter `error_body_formatter` with type `ErrorBodyFormatter | None` in function `libs.external_api.ExternalApi.__init__` [bad-argument-type]
- --> tests/unit_tests/libs/test_external_api.py:285:72
+ --> tests/unit_tests/libs/test_external_api.py:284:72
ERROR Argument `Unknown | None` is not assignable to parameter `blueprint` with type `Blueprint` in function `flask.sansio.app.App.register_blueprint` [bad-argument-type]
- --> tests/unit_tests/libs/test_external_api.py:399:28
+ --> tests/unit_tests/libs/test_external_api.py:398:28
ERROR Cannot index into `str` [bad-index]
- --> tests/unit_tests/libs/test_external_api.py:435:12
+ --> tests/unit_tests/libs/test_external_api.py:434:12
ERROR Cannot index into `bool` [bad-index]
- --> tests/unit_tests/libs/test_external_api.py:436:12
+ --> tests/unit_tests/libs/test_external_api.py:435:12
ERROR Cannot index into `str` [bad-index]
- --> tests/unit_tests/libs/test_external_api.py:436:12
+ --> tests/unit_tests/libs/test_external_api.py:435:12
ERROR Class member `User.get_id` overrides a member in a parent class but is missing an `@override` decorator [missing-override-decorator]
--> tests/unit_tests/libs/test_flask_utils.py:18:9
ERROR `str` is not assignable to dict key `error` with type `None` [bad-assignment]
@@ -5779,53 +5799,53 @@
ERROR Argument `Literal['emoji']` is not assignable to parameter `icon_type` with type `AgentIconType | SQLCoreOperations[AgentIconType | None] | None` in function `models.agent.Agent.__init__` [bad-argument-type]
--> tests/unit_tests/services/agent/test_roster_service.py:2497:19
ERROR Argument `Literal['emoji']` is not assignable to parameter `icon_type` with type `AgentIconType | SQLCoreOperations[AgentIconType | None] | None` in function `models.agent.Agent.__init__` [bad-argument-type]
- --> tests/unit_tests/services/agent/test_roster_service.py:2653:19
+ --> tests/unit_tests/services/agent/test_roster_service.py:2652:19
ERROR Object of class `object` has no attribute `prompt` [missing-attribute]
- --> tests/unit_tests/services/agent/test_roster_service.py:3073:12
+ --> tests/unit_tests/services/agent/test_roster_service.py:3064:12
ERROR Cannot index into `object` [bad-index]
- --> tests/unit_tests/services/agent/test_roster_service.py:3264:12
+ --> tests/unit_tests/services/agent/test_roster_service.py:3255:12
ERROR Cannot index into `object` [bad-index]
- --> tests/unit_tests/services/agent/test_roster_service.py:3265:12
+ --> tests/unit_tests/services/agent/test_roster_service.py:3256:12
ERROR Cannot index into `object` [bad-index]
- --> tests/unit_tests/services/agent/test_roster_service.py:3266:12
+ --> tests/unit_tests/services/agent/test_roster_service.py:3257:12
ERROR Argument `list[str | None]` is not assignable to parameter `version_ids` with type `list[str]` in function `services.agent.roster_service.AgentRosterService._load_versions_by_id` [bad-argument-type]
- --> tests/unit_tests/services/agent/test_roster_service.py:4371:52
+ --> tests/unit_tests/services/agent/test_roster_service.py:4362:52
ERROR Argument `Literal[0]` is not assignable to parameter `message_unit_price` with type `Decimal | SQLCoreOperations[Decimal]` in function `models.model.Message.__init__` [bad-argument-type]
- --> tests/unit_tests/services/agent/test_roster_service.py:4530:36
+ --> tests/unit_tests/services/agent/test_roster_service.py:4521:36
ERROR Argument `Literal[0]` is not assignable to parameter `answer_unit_price` with type `Decimal | SQLCoreOperations[Decimal]` in function `models.model.Message.__init__` [bad-argument-type]
- --> tests/unit_tests/services/agent/test_roster_service.py:4532:35
+ --> tests/unit_tests/services/agent/test_roster_service.py:4523:35
ERROR Argument `Literal[0]` is not assignable to parameter `total_price` with type `Decimal | SQLCoreOperations[Decimal | None] | None` in function `models.model.Message.__init__` [bad-argument-type]
- --> tests/unit_tests/services/agent/test_roster_service.py:4533:29
+ --> tests/unit_tests/services/agent/test_roster_service.py:4524:29
ERROR Object of class `NoneType` has no attribute `conversation_id` [missing-attribute]
- --> tests/unit_tests/services/agent/test_roster_service.py:5306:16
+ --> tests/unit_tests/services/agent/test_roster_service.py:5297:16
ERROR Argument `Literal['simple']` is not assignable to parameter `prompt_type` with type `PromptType | SQLCoreOperations[PromptType]` in function `models.model.AppModelConfig.__init__` [bad-argument-type]
- --> tests/unit_tests/services/agent/test_roster_service.py:5410:25
+ --> tests/unit_tests/services/agent/test_roster_service.py:5401:25
ERROR Unpacked keyword argument `Any | None` is not assignable to parameter `prompt_type` with type `PromptType | SQLCoreOperations[PromptType]` in function `models.model.AppModelConfig.__init__` [bad-argument-type]
- --> tests/unit_tests/services/agent/test_roster_service.py:5418:34
+ --> tests/unit_tests/services/agent/test_roster_service.py:5409:34
ERROR Object of class `object` has no attribute `name` [missing-attribute]
- --> tests/unit_tests/services/agent/test_roster_service.py:5524:16
+ --> tests/unit_tests/services/agent/test_roster_service.py:5515:16
ERROR Object of class `object` has no attribute `mode` [missing-attribute]
- --> tests/unit_tests/services/agent/test_roster_service.py:5525:16
+ --> tests/unit_tests/services/agent/test_roster_service.py:5516:16
ERROR Object of class `object` has no attribute `agent_role` [missing-attribute]
- --> tests/unit_tests/services/agent/test_roster_service.py:5526:16
+ --> tests/unit_tests/services/agent/test_roster_service.py:5517:16
ERROR Object of class `object` has no attribute `config_snapshot` [missing-attribute]
- --> tests/unit_tests/services/agent/test_roster_service.py:5536:16
+ --> tests/unit_tests/services/agent/test_roster_service.py:5527:16
ERROR Object of class `object` has no attribute `home_snapshot_id` [missing-attribute]
- --> tests/unit_tests/services/agent/test_roster_service.py:5538:16
+ --> tests/unit_tests/services/agent/test_roster_service.py:5529:16
ERROR Object of class `object` has no attribute `summary` [missing-attribute]
- --> tests/unit_tests/services/agent/test_roster_service.py:5539:16
+ --> tests/unit_tests/services/agent/test_roster_service.py:5530:16
ERROR Object of class `object` has no attribute `version_note` [missing-attribute]
- --> tests/unit_tests/services/agent/test_roster_service.py:5540:16
+ --> tests/unit_tests/services/agent/test_roster_service.py:5531:16
ERROR Object of class `object` has no attribute `active_config_has_model` [missing-attribute]
- --> tests/unit_tests/services/agent/test_roster_service.py:5541:16
+ --> tests/unit_tests/services/agent/test_roster_service.py:5532:16
ERROR Object of class `object` has no attribute `active_config_is_published` [missing-attribute]
- --> tests/unit_tests/services/agent/test_roster_service.py:5542:16
+ --> tests/unit_tests/services/agent/test_roster_service.py:5533:16
ERROR Object of class `object` has no attribute `updated_by` [missing-attribute]
- --> tests/unit_tests/services/agent/test_roster_service.py:5543:16
+ --> tests/unit_tests/services/agent/test_roster_service.py:5534:16
ERROR Object of class `object` has no attribute `id` [missing-attribute]
- --> tests/unit_tests/services/agent/test_roster_service.py:5544:35
+ --> tests/unit_tests/services/agent/test_roster_service.py:5535:35
ERROR Object of class `object` has no attribute `agent_role` [missing-attribute]
- --> tests/unit_tests/services/agent/test_roster_service.py:5614:16
+ --> tests/unit_tests/services/agent/test_roster_service.py:5605:16
ERROR Argument `object` is not assignable to parameter `pwd` with type `bytes | None` in function `zipfile.ZipFile.read` [bad-argument-type]
--> tests/unit_tests/services/agent/test_skill_package_service.py:306:44
ERROR Object of class `NoneType` has no attribute `node_job_config_dict` [missing-attribute]
@@ -5866,6 +5886,14 @@
--> tests/unit_tests/services/enterprise/test_plugin_manager_service.py:59:25
ERROR Argument `None` is not assignable to parameter `response` with type `Response` in function `httpx._exceptions.HTTPStatusError.__init__` [bad-argument-type]
--> tests/unit_tests/services/enterprise/test_plugin_manager_service.py:60:26
+ERROR Object of class `FromClause` has no attribute `create` [missing-attribute]
+ --> tests/unit_tests/services/errors/test_plugin.py:55:13
+ERROR Object of class `NoneType` has no attribute `version` [missing-attribute]
+ --> tests/unit_tests/services/errors/test_plugin.py:85:16
+ERROR Object of class `NoneType` has no attribute `version` [missing-attribute]
+ --> tests/unit_tests/services/errors/test_plugin.py:103:16
+ERROR Object of class `NoneType` has no attribute `credential_id` [missing-attribute]
+ --> tests/unit_tests/services/errors/test_plugin.py:570:16
ERROR Argument `str` is not assignable to parameter `type` with type `Literal['basic', 'bearer', 'custom'] | None` in function `services.entities.external_knowledge_entities.external_knowledge_entities.AuthorizationConfig.__init__` [bad-argument-type]
--> tests/unit_tests/services/knowledge/external/test_service.py:116:60
ERROR Argument `str` is not assignable to parameter `type` with type `Literal['api-key', 'no-auth']` in function `services.entities.external_knowledge_entities.external_knowledge_entities.Authorization.__init__` [bad-argument-type]
@@ -5989,17 +6017,17 @@
ERROR `in` is not supported between `Literal['not found']` and `None` [not-iterable]
--> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:894:16
ERROR Argument `SimpleNamespace` is not assignable to parameter `version` with type `AgentConfigDraft | AgentConfigSnapshot` in function `services.agent_config_service.AgentConfigTarget.__init__` [bad-argument-type]
- --> tests/unit_tests/services/test_agent_config_service.py:161:17
+ --> tests/unit_tests/services/test_agent_config_service.py:159:17
ERROR Cannot index into `object` [bad-index]
- --> tests/unit_tests/services/test_agent_config_service.py:1021:12
+ --> tests/unit_tests/services/test_agent_config_service.py:1023:12
ERROR Type `object` is not iterable [not-iterable]
- --> tests/unit_tests/services/test_agent_config_service.py:1022:38
+ --> tests/unit_tests/services/test_agent_config_service.py:1024:38
ERROR Cannot index into `object` [bad-index]
- --> tests/unit_tests/services/test_agent_config_service.py:1179:38
+ --> tests/unit_tests/services/test_agent_config_service.py:1181:38
ERROR Cannot index into `object` [bad-index]
- --> tests/unit_tests/services/test_agent_config_service.py:1180:12
+ --> tests/unit_tests/services/test_agent_config_service.py:1182:12
ERROR Type `object` is not iterable [not-iterable]
- --> tests/unit_tests/services/test_agent_config_service.py:1216:38
+ --> tests/unit_tests/services/test_agent_config_service.py:1218:38
ERROR Object of class `FromClause` has no attribute `create` [missing-attribute]
--> tests/unit_tests/services/test_api_token_service.py:309:13
ERROR Argument `Literal['app']` is not assignable to parameter `value` with type `ApiTokenType | SQLCoreOperations[ApiTokenType]` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
@@ -6132,6 +6160,14 @@
--> tests/unit_tests/services/test_snippet_service.py:1035:9
ERROR Object of class `NoneType` has no attribute `use_count` [missing-attribute]
--> tests/unit_tests/services/test_snippet_service.py:1090:12
+ERROR Cannot set item in `dict[str, int]` [unsupported-operation]
+ --> tests/unit_tests/services/test_variable_truncator.py:147:35
+ERROR Argument `list[File]` is not assignable to parameter `value` with type `list[object]` in function `services.variable_truncator.VariableTruncator._truncate_array` [bad-argument-type]
+ --> tests/unit_tests/services/test_variable_truncator.py:724:48
+ERROR Argument `list[File]` is not assignable to parameter `value` with type `list[object]` in function `services.variable_truncator.VariableTruncator._truncate_array` [bad-argument-type]
+ --> tests/unit_tests/services/test_variable_truncator.py:736:48
+ERROR Argument `list[File]` is not assignable to parameter `value` with type `list[object]` in function `services.variable_truncator.VariableTruncator._truncate_array` [bad-argument-type]
+ --> tests/unit_tests/services/test_variable_truncator.py:751:48
ERROR Argument `list[FromClause]` is not assignable to parameter `tables` with type `Sequence[Table] | None` in function `sqlalchemy.sql.schema.MetaData.create_all` [bad-argument-type]
--> tests/unit_tests/services/test_workflow_collaboration_service.py:47:56
WARN Call to deprecated overload `contextlib.contextmanager` [deprecated]
@@ -6504,3 +6540,17 @@
--> tests/unit_tests/tasks/test_human_input_timeout_tasks.py:214:12
ERROR Object of class `NoneType` has no attribute `status` [missing-attribute]
--> tests/unit_tests/tasks/test_human_input_timeout_tasks.py:215:12
+ERROR Object of class `ModuleType` has no attribute `is_enabled` [missing-attribute]
+ --> tests/unit_tests/tasks/test_ops_trace_task.py:54:5
+ERROR Object of class `ModuleType` has no attribute `OpsTraceManager` [missing-attribute]
+ --> tests/unit_tests/tasks/test_ops_trace_task.py:56:5
+ERROR Object of class `ModuleType` has no attribute `EnterpriseOtelTrace` [missing-attribute]
+ --> tests/unit_tests/tasks/test_ops_trace_task.py:65:9
+ERROR Missing argument `file_info` in function `celery.app.task.Task.push_request` [missing-argument]
+ --> tests/unit_tests/tasks/test_ops_trace_task.py:91:37
+ERROR Unexpected keyword argument `retries` in function `celery.app.task.Task.push_request` [unexpected-keyword]
+ --> tests/unit_tests/tasks/test_ops_trace_task.py:91:38
+ERROR `*` is not supported between `None` and `int` [unsupported-operation]
+ --> tests/unit_tests/tasks/test_ops_trace_task.py:252:9
+ERROR Argument `int | None` is not assignable to parameter `retries` with type `int` in function `_run_task` [bad-argument-type]
+ --> tests/unit_tests/tasks/test_ops_trace_task.py:332:38
|
Pyrefly Type Coverage
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #45000 +/- ##
=======================================
Coverage 90.27% 90.27%
=======================================
Files 6459 6459
Lines 407411 407411
Branches 81799 81799
=======================================
+ Hits 367782 367787 +5
+ Misses 33221 33214 -7
- Partials 6408 6410 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
asukaminato0721
left a comment
There was a problem hiding this comment.
1 inline suggestion at 64f3467069, from a rule learned from earlier reviews in this repository. Reply on the comment if it is wrong.
dify-codereview
asukaminato0721
left a comment
There was a problem hiding this comment.
CI is failing: Style Check / Python Style. Please fix it. Checked 64f3467069.
dify-codereview
asukaminato0721
left a comment
There was a problem hiding this comment.
Nothing to flag at 54518cc55a.
dify-codereview
Nothing left to flag at 54518cc.
Summary
Part of #44973.
test_message_transformer.pypatchedSessionanddbwith aMagicMocksession whosescalarreturned a made-up tool file (orNone). The two tool-file lookup tests now use the sharedsqlite_engineandsqlite_sessionfixtures with realToolFilerows, and I added a test that a tool file belonging to another tenant is rejected, which can only be checked against a real query.Checked: temporarily inverting the tenant filter in
_file_from_link_message(==to!=) made both the promotion test and the new tenant test fail; I restored the file afterwards. Theagentnode test folder andruff check/ruff format --checkpass.Left untouched: the other tests in this file.
Screenshots
N/A (test-only change)
Checklist
make lint && make type-check(backend) andvp staged(frontend) to appease the lint gods