Skip to content

refactor(api): replace json.loads with Pydantic validation in services layer - #33704

Merged
asukaminato0721 merged 15 commits into
langgenius:mainfrom
fury0928:refactor/replace-json-loads-with-pydantic-services
Mar 30, 2026
Merged

asukaminato0721 merged 15 commits into
langgenius:mainfrom
fury0928:refactor/replace-json-loads-with-pydantic-services

Conversation

@fury0928

@fury0928 fury0928 commented Mar 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Replace raw json.loads calls with Pydantic validate_json and model_validate_json across 14 service files for type-safe JSON deserialization.

Why this change

The services layer used bare json.loads which returns untyped dicts, bypassing runtime validation. Pydantic's validate_json gives schema validation on deserialization and typed return values for static type checkers.

Key patterns applied

  • Module-level TypeAdapter instances for reused adapters (avoids repeated schema compilation)
  • validate_json over json.loads + validate_python (single-pass parsing + validation)
  • model_validate_json for Pydantic models deserialized from JSON
  • TypedDict for structured records in plugin_migration
  • ValidationError replaces JSONDecodeError where applicable

Test plan

  • CI lint + type-check pass
  • CI full test suite passes

Part of #33092

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. refactor labels Mar 19, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the API's services layer by migrating from untyped json.loads() calls to Pydantic's robust validation mechanisms. The primary goal is to enhance data integrity and type safety by ensuring that JSON data consumed by various services conforms to predefined schemas. This change provides immediate validation upon deserialization, preventing issues caused by malformed or unexpected data structures from propagating further into the application, and improves the overall reliability and maintainability of the codebase.

Highlights

  • Enhanced Type Safety: Replaced raw json.loads() calls with Pydantic's TypeAdapter.validate_json() and model_validate_json() across the services layer to ensure type-safe JSON deserialization.
  • Schema Validation: Introduced schema validation at the data boundary, catching malformed data earlier and providing typed return values that satisfy static type checkers.
  • Optimized Pydantic Usage: Implemented module-level TypeAdapter instances for frequently reused schemas to avoid repeated compilation, and utilized validate_json() for single-pass parsing and validation.
  • Error Handling Improvement: Replaced JSONDecodeError exceptions with Pydantic's ValidationError where applicable, standardizing error handling for data validation.
  • TypedDict Integration: Leveraged TypedDict for structured records, such as _TenantPluginRecord in plugin_migration, to improve data structure clarity and validation.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-03-19 01:10:23.638555957 +0000
+++ /tmp/pyrefly_pr.txt	2026-03-19 01:10:14.897623260 +0000
@@ -12,6 +12,18 @@
    --> controllers/console/app/site.py:122:5
 ERROR Argument `str | None` is not assignable to parameter `language` with type `str` in function `services.account_service.AccountService.send_email_register_email` [bad-argument-type]
   --> controllers/console/auth/email_register.py:78:108
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.get_oauth_client` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:128:23
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:136:23
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:137:21
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.reauthorize_datasource_oauth_provider` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:147:27
+ERROR Argument `Any | None` is not assignable to parameter `credential_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.reauthorize_datasource_oauth_provider` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:153:31
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.add_datasource_oauth_provider` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:157:27
 ERROR Argument `WorkflowRun | None` is not assignable to parameter `workflow_run` with type `WorkflowRun` in function `services.workflow_event_snapshot_service.build_workflow_event_stream` [bad-argument-type]
    --> controllers/console/human_input_form.py:183:42
 ERROR Object of class `NoneType` has no attribute `tenant_id` [missing-attribute]
@@ -32,6 +44,26 @@
   --> controllers/console/setup.py:64:2
 ERROR Object of class `MissingRouter` has no attribute `get` [missing-attribute]
   --> controllers/console/version.py:30:2
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.tools.builtin_tools_manage_service.BuiltinToolManageService.get_oauth_client` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:838:73
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:844:23
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:845:21
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `services.tools.builtin_tools_manage_service.BuiltinToolManageService.add_builtin_tool_provider` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:861:21
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.tools.builtin_tools_manage_service.BuiltinToolManageService.add_builtin_tool_provider` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:862:23
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.trigger.trigger_provider_service.TriggerProviderService.get_oauth_client` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:508:23
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:520:23
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:521:21
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.trigger.trigger_subscription_builder_service.TriggerSubscriptionBuilderService.update_trigger_subscription_builder` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:537:23
+ERROR Argument `Any | None` is not assignable to parameter `subscription_builder_id` with type `str` in function `services.trigger.trigger_subscription_builder_service.TriggerSubscriptionBuilderService.update_trigger_subscription_builder` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:539:37
 ERROR `result` may be uninitialized [unbound-name]
   --> controllers/service_api/app/annotation.py:55:16
 ERROR Argument `WorkflowRun | None` is not assignable to parameter `workflow_run` with type `WorkflowRun` in function `services.workflow_event_snapshot_service.build_workflow_event_stream` [bad-argument-type]
@@ -528,11 +560,11 @@
 ERROR Argument `str | None` is not assignable to parameter `value` with type `SQLCoreOperations[str] | str` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
    --> services/conversation_service.py:131:33
 ERROR `dict[str, bool | dict[str, Any] | str | None]` is not assignable to variable `data_source_info` with type `dict[str, bool | str]` [bad-assignment]
-    --> services/dataset_service.py:2095:56
+    --> services/dataset_service.py:2098:56
 ERROR `dict[str, bool | dict[str, Any] | str | None]` is not assignable to variable `data_source_info` with type `dict[str, bool | str]` [bad-assignment]
-    --> services/dataset_service.py:2607:44
+    --> services/dataset_service.py:2610:44
 ERROR `None` is not assignable to attribute `rules` with type `Never` [bad-assignment]
-    --> services/dataset_service.py:2780:51
+    --> services/dataset_service.py:2783:51
 ERROR Class member `DocumentIndexingTaskProxy.NORMAL_TASK_FUNC` overrides parent class `BatchDocumentIndexingProxy` in an inconsistent manner [bad-override]
   --> services/document_indexing_proxy/document_indexing_task_proxy.py:11:5
 ERROR Class member `DocumentIndexingTaskProxy.PRIORITY_TASK_FUNC` overrides parent class `BatchDocumentIndexingProxy` in an inconsistent manner [bad-override]
@@ -549,8 +581,16 @@
    --> services/external_knowledge_service.py:230:17
 ERROR Returned type `dict[Unknown, Unknown] | None` is not assignable to declared return type `dict[str, Any]` [bad-return]
    --> services/external_knowledge_service.py:232:16
+ERROR Argument `dict[str, Any]` is not assignable to parameter `model_config` with type `AppModelConfigDict` in function `models.model.AppModelConfig.from_model_config_dict` [bad-argument-type]
+   --> services/message_service.py:295:76
+ERROR Could not find name `json` [unknown-name]
+   --> services/model_load_balancing_service.py:414:62
+ERROR Could not find name `json` [unknown-name]
+   --> services/model_load_balancing_service.py:468:42
+ERROR Argument `object | Unknown` is not assignable to parameter `token` with type `str` in function `core.helper.encrypter.decrypt_token` [bad-argument-type]
+   --> services/model_load_balancing_service.py:586:79
 ERROR `handled_tenant_count` was assigned in the current scope before the nonlocal declaration [unknown-name]
-  --> services/plugin/plugin_migration.py:72:34
+  --> services/plugin/plugin_migration.py:82:34
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
    --> services/summary_index_service.py:285:29
 ERROR Object of class `NoneType` has no attribute `summary_index_node_id` [missing-attribute]

@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-03-19 01:12:22.015725184 +0000
+++ /tmp/pyrefly_pr.txt	2026-03-19 01:12:12.908743538 +0000
@@ -12,6 +12,18 @@
    --> controllers/console/app/site.py:122:5
 ERROR Argument `str | None` is not assignable to parameter `language` with type `str` in function `services.account_service.AccountService.send_email_register_email` [bad-argument-type]
   --> controllers/console/auth/email_register.py:78:108
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.get_oauth_client` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:128:23
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:136:23
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:137:21
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.reauthorize_datasource_oauth_provider` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:147:27
+ERROR Argument `Any | None` is not assignable to parameter `credential_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.reauthorize_datasource_oauth_provider` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:153:31
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.add_datasource_oauth_provider` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:157:27
 ERROR Argument `WorkflowRun | None` is not assignable to parameter `workflow_run` with type `WorkflowRun` in function `services.workflow_event_snapshot_service.build_workflow_event_stream` [bad-argument-type]
    --> controllers/console/human_input_form.py:183:42
 ERROR Object of class `NoneType` has no attribute `tenant_id` [missing-attribute]
@@ -32,6 +44,26 @@
   --> controllers/console/setup.py:64:2
 ERROR Object of class `MissingRouter` has no attribute `get` [missing-attribute]
   --> controllers/console/version.py:30:2
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.tools.builtin_tools_manage_service.BuiltinToolManageService.get_oauth_client` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:838:73
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:844:23
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:845:21
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `services.tools.builtin_tools_manage_service.BuiltinToolManageService.add_builtin_tool_provider` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:861:21
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.tools.builtin_tools_manage_service.BuiltinToolManageService.add_builtin_tool_provider` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:862:23
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.trigger.trigger_provider_service.TriggerProviderService.get_oauth_client` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:508:23
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:520:23
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:521:21
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.trigger.trigger_subscription_builder_service.TriggerSubscriptionBuilderService.update_trigger_subscription_builder` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:537:23
+ERROR Argument `Any | None` is not assignable to parameter `subscription_builder_id` with type `str` in function `services.trigger.trigger_subscription_builder_service.TriggerSubscriptionBuilderService.update_trigger_subscription_builder` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:539:37
 ERROR `result` may be uninitialized [unbound-name]
   --> controllers/service_api/app/annotation.py:55:16
 ERROR Argument `WorkflowRun | None` is not assignable to parameter `workflow_run` with type `WorkflowRun` in function `services.workflow_event_snapshot_service.build_workflow_event_stream` [bad-argument-type]
@@ -528,11 +560,11 @@
 ERROR Argument `str | None` is not assignable to parameter `value` with type `SQLCoreOperations[str] | str` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
    --> services/conversation_service.py:131:33
 ERROR `dict[str, bool | dict[str, Any] | str | None]` is not assignable to variable `data_source_info` with type `dict[str, bool | str]` [bad-assignment]
-    --> services/dataset_service.py:2095:56
+    --> services/dataset_service.py:2096:56
 ERROR `dict[str, bool | dict[str, Any] | str | None]` is not assignable to variable `data_source_info` with type `dict[str, bool | str]` [bad-assignment]
-    --> services/dataset_service.py:2607:44
+    --> services/dataset_service.py:2608:44
 ERROR `None` is not assignable to attribute `rules` with type `Never` [bad-assignment]
-    --> services/dataset_service.py:2780:51
+    --> services/dataset_service.py:2781:51
 ERROR Class member `DocumentIndexingTaskProxy.NORMAL_TASK_FUNC` overrides parent class `BatchDocumentIndexingProxy` in an inconsistent manner [bad-override]
   --> services/document_indexing_proxy/document_indexing_task_proxy.py:11:5
 ERROR Class member `DocumentIndexingTaskProxy.PRIORITY_TASK_FUNC` overrides parent class `BatchDocumentIndexingProxy` in an inconsistent manner [bad-override]
@@ -549,8 +581,16 @@
    --> services/external_knowledge_service.py:230:17
 ERROR Returned type `dict[Unknown, Unknown] | None` is not assignable to declared return type `dict[str, Any]` [bad-return]
    --> services/external_knowledge_service.py:232:16
+ERROR Argument `dict[str, Any]` is not assignable to parameter `model_config` with type `AppModelConfigDict` in function `models.model.AppModelConfig.from_model_config_dict` [bad-argument-type]
+   --> services/message_service.py:295:76
+ERROR Could not find name `json` [unknown-name]
+   --> services/model_load_balancing_service.py:414:62
+ERROR Could not find name `json` [unknown-name]
+   --> services/model_load_balancing_service.py:468:42
+ERROR Argument `object | Unknown` is not assignable to parameter `token` with type `str` in function `core.helper.encrypter.decrypt_token` [bad-argument-type]
+   --> services/model_load_balancing_service.py:586:79
 ERROR `handled_tenant_count` was assigned in the current scope before the nonlocal declaration [unknown-name]
-  --> services/plugin/plugin_migration.py:72:34
+  --> services/plugin/plugin_migration.py:82:34
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
    --> services/summary_index_service.py:285:29
 ERROR Object of class `NoneType` has no attribute `summary_index_node_id` [missing-attribute]

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request is a great refactoring that replaces raw json.loads() calls with Pydantic's validation methods across the services layer. This significantly improves type safety and data validation at the boundaries. My review focuses on a few opportunities to further enhance performance by optimizing the usage of Pydantic's TypeAdapter and simplifying data handling, which are consistent with the goals of this refactoring.

Comment thread api/services/account_service.py Resolved
Comment thread api/services/billing_service.py Resolved
Comment thread api/services/dataset_service.py Resolved
Comment thread api/services/dataset_service.py Resolved
Comment thread api/services/message_service.py Resolved
Comment thread api/services/workflow_service.py Resolved
@fury0928
fury0928 force-pushed the refactor/replace-json-loads-with-pydantic-services branch from 7f25c64 to e3fb186 Compare March 19, 2026 01:19
@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-03-19 01:20:16.999105362 +0000
+++ /tmp/pyrefly_pr.txt	2026-03-19 01:20:08.249102284 +0000
@@ -12,6 +12,18 @@
    --> controllers/console/app/site.py:122:5
 ERROR Argument `str | None` is not assignable to parameter `language` with type `str` in function `services.account_service.AccountService.send_email_register_email` [bad-argument-type]
   --> controllers/console/auth/email_register.py:78:108
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.get_oauth_client` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:128:23
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:136:23
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:137:21
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.reauthorize_datasource_oauth_provider` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:147:27
+ERROR Argument `Any | None` is not assignable to parameter `credential_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.reauthorize_datasource_oauth_provider` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:153:31
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.add_datasource_oauth_provider` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:157:27
 ERROR Argument `WorkflowRun | None` is not assignable to parameter `workflow_run` with type `WorkflowRun` in function `services.workflow_event_snapshot_service.build_workflow_event_stream` [bad-argument-type]
    --> controllers/console/human_input_form.py:183:42
 ERROR Object of class `NoneType` has no attribute `tenant_id` [missing-attribute]
@@ -32,6 +44,26 @@
   --> controllers/console/setup.py:64:2
 ERROR Object of class `MissingRouter` has no attribute `get` [missing-attribute]
   --> controllers/console/version.py:30:2
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.tools.builtin_tools_manage_service.BuiltinToolManageService.get_oauth_client` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:838:73
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:844:23
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:845:21
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `services.tools.builtin_tools_manage_service.BuiltinToolManageService.add_builtin_tool_provider` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:861:21
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.tools.builtin_tools_manage_service.BuiltinToolManageService.add_builtin_tool_provider` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:862:23
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.trigger.trigger_provider_service.TriggerProviderService.get_oauth_client` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:508:23
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:520:23
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:521:21
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.trigger.trigger_subscription_builder_service.TriggerSubscriptionBuilderService.update_trigger_subscription_builder` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:537:23
+ERROR Argument `Any | None` is not assignable to parameter `subscription_builder_id` with type `str` in function `services.trigger.trigger_subscription_builder_service.TriggerSubscriptionBuilderService.update_trigger_subscription_builder` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:539:37
 ERROR `result` may be uninitialized [unbound-name]
   --> controllers/service_api/app/annotation.py:55:16
 ERROR Argument `WorkflowRun | None` is not assignable to parameter `workflow_run` with type `WorkflowRun` in function `services.workflow_event_snapshot_service.build_workflow_event_stream` [bad-argument-type]
@@ -528,11 +560,11 @@
 ERROR Argument `str | None` is not assignable to parameter `value` with type `SQLCoreOperations[str] | str` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
    --> services/conversation_service.py:131:33
 ERROR `dict[str, bool | dict[str, Any] | str | None]` is not assignable to variable `data_source_info` with type `dict[str, bool | str]` [bad-assignment]
-    --> services/dataset_service.py:2095:56
+    --> services/dataset_service.py:2098:56
 ERROR `dict[str, bool | dict[str, Any] | str | None]` is not assignable to variable `data_source_info` with type `dict[str, bool | str]` [bad-assignment]
-    --> services/dataset_service.py:2607:44
+    --> services/dataset_service.py:2610:44
 ERROR `None` is not assignable to attribute `rules` with type `Never` [bad-assignment]
-    --> services/dataset_service.py:2780:51
+    --> services/dataset_service.py:2783:51
 ERROR Class member `DocumentIndexingTaskProxy.NORMAL_TASK_FUNC` overrides parent class `BatchDocumentIndexingProxy` in an inconsistent manner [bad-override]
   --> services/document_indexing_proxy/document_indexing_task_proxy.py:11:5
 ERROR Class member `DocumentIndexingTaskProxy.PRIORITY_TASK_FUNC` overrides parent class `BatchDocumentIndexingProxy` in an inconsistent manner [bad-override]
@@ -549,8 +581,16 @@
    --> services/external_knowledge_service.py:230:17
 ERROR Returned type `dict[Unknown, Unknown] | None` is not assignable to declared return type `dict[str, Any]` [bad-return]
    --> services/external_knowledge_service.py:232:16
+ERROR Argument `dict[str, Any]` is not assignable to parameter `model_config` with type `AppModelConfigDict` in function `models.model.AppModelConfig.from_model_config_dict` [bad-argument-type]
+   --> services/message_service.py:295:76
+ERROR Could not find name `json` [unknown-name]
+   --> services/model_load_balancing_service.py:414:62
+ERROR Could not find name `json` [unknown-name]
+   --> services/model_load_balancing_service.py:468:42
+ERROR Argument `object | Unknown` is not assignable to parameter `token` with type `str` in function `core.helper.encrypter.decrypt_token` [bad-argument-type]
+   --> services/model_load_balancing_service.py:586:79
 ERROR `handled_tenant_count` was assigned in the current scope before the nonlocal declaration [unknown-name]
-  --> services/plugin/plugin_migration.py:72:34
+  --> services/plugin/plugin_migration.py:82:34
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
    --> services/summary_index_service.py:285:29
 ERROR Object of class `NoneType` has no attribute `summary_index_node_id` [missing-attribute]

@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-03-19 01:22:19.644214431 +0000
+++ /tmp/pyrefly_pr.txt	2026-03-19 01:22:10.502139491 +0000
@@ -12,6 +12,18 @@
    --> controllers/console/app/site.py:122:5
 ERROR Argument `str | None` is not assignable to parameter `language` with type `str` in function `services.account_service.AccountService.send_email_register_email` [bad-argument-type]
   --> controllers/console/auth/email_register.py:78:108
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.get_oauth_client` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:128:23
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:136:23
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:137:21
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.reauthorize_datasource_oauth_provider` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:147:27
+ERROR Argument `Any | None` is not assignable to parameter `credential_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.reauthorize_datasource_oauth_provider` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:153:31
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.add_datasource_oauth_provider` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:157:27
 ERROR Argument `WorkflowRun | None` is not assignable to parameter `workflow_run` with type `WorkflowRun` in function `services.workflow_event_snapshot_service.build_workflow_event_stream` [bad-argument-type]
    --> controllers/console/human_input_form.py:183:42
 ERROR Object of class `NoneType` has no attribute `tenant_id` [missing-attribute]
@@ -32,6 +44,26 @@
   --> controllers/console/setup.py:64:2
 ERROR Object of class `MissingRouter` has no attribute `get` [missing-attribute]
   --> controllers/console/version.py:30:2
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.tools.builtin_tools_manage_service.BuiltinToolManageService.get_oauth_client` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:838:73
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:844:23
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:845:21
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `services.tools.builtin_tools_manage_service.BuiltinToolManageService.add_builtin_tool_provider` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:861:21
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.tools.builtin_tools_manage_service.BuiltinToolManageService.add_builtin_tool_provider` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:862:23
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.trigger.trigger_provider_service.TriggerProviderService.get_oauth_client` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:508:23
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:520:23
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:521:21
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.trigger.trigger_subscription_builder_service.TriggerSubscriptionBuilderService.update_trigger_subscription_builder` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:537:23
+ERROR Argument `Any | None` is not assignable to parameter `subscription_builder_id` with type `str` in function `services.trigger.trigger_subscription_builder_service.TriggerSubscriptionBuilderService.update_trigger_subscription_builder` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:539:37
 ERROR `result` may be uninitialized [unbound-name]
   --> controllers/service_api/app/annotation.py:55:16
 ERROR Argument `WorkflowRun | None` is not assignable to parameter `workflow_run` with type `WorkflowRun` in function `services.workflow_event_snapshot_service.build_workflow_event_stream` [bad-argument-type]
@@ -528,11 +560,11 @@
 ERROR Argument `str | None` is not assignable to parameter `value` with type `SQLCoreOperations[str] | str` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
    --> services/conversation_service.py:131:33
 ERROR `dict[str, bool | dict[str, Any] | str | None]` is not assignable to variable `data_source_info` with type `dict[str, bool | str]` [bad-assignment]
-    --> services/dataset_service.py:2095:56
+    --> services/dataset_service.py:2096:56
 ERROR `dict[str, bool | dict[str, Any] | str | None]` is not assignable to variable `data_source_info` with type `dict[str, bool | str]` [bad-assignment]
-    --> services/dataset_service.py:2607:44
+    --> services/dataset_service.py:2608:44
 ERROR `None` is not assignable to attribute `rules` with type `Never` [bad-assignment]
-    --> services/dataset_service.py:2780:51
+    --> services/dataset_service.py:2781:51
 ERROR Class member `DocumentIndexingTaskProxy.NORMAL_TASK_FUNC` overrides parent class `BatchDocumentIndexingProxy` in an inconsistent manner [bad-override]
   --> services/document_indexing_proxy/document_indexing_task_proxy.py:11:5
 ERROR Class member `DocumentIndexingTaskProxy.PRIORITY_TASK_FUNC` overrides parent class `BatchDocumentIndexingProxy` in an inconsistent manner [bad-override]
@@ -549,8 +581,16 @@
    --> services/external_knowledge_service.py:230:17
 ERROR Returned type `dict[Unknown, Unknown] | None` is not assignable to declared return type `dict[str, Any]` [bad-return]
    --> services/external_knowledge_service.py:232:16
+ERROR Argument `dict[str, Any]` is not assignable to parameter `model_config` with type `AppModelConfigDict` in function `models.model.AppModelConfig.from_model_config_dict` [bad-argument-type]
+   --> services/message_service.py:295:76
+ERROR Could not find name `json` [unknown-name]
+   --> services/model_load_balancing_service.py:414:62
+ERROR Could not find name `json` [unknown-name]
+   --> services/model_load_balancing_service.py:468:42
+ERROR Argument `object | Unknown` is not assignable to parameter `token` with type `str` in function `core.helper.encrypter.decrypt_token` [bad-argument-type]
+   --> services/model_load_balancing_service.py:586:79
 ERROR `handled_tenant_count` was assigned in the current scope before the nonlocal declaration [unknown-name]
-  --> services/plugin/plugin_migration.py:72:34
+  --> services/plugin/plugin_migration.py:82:34
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
    --> services/summary_index_service.py:285:29
 ERROR Object of class `NoneType` has no attribute `summary_index_node_id` [missing-attribute]

@fury0928
fury0928 requested a review from laipz8200 as a code owner March 19, 2026 01:52
@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-03-19 01:53:23.828845502 +0000
+++ /tmp/pyrefly_pr.txt	2026-03-19 01:53:14.255909445 +0000
@@ -12,6 +12,18 @@
    --> controllers/console/app/site.py:122:5
 ERROR Argument `str | None` is not assignable to parameter `language` with type `str` in function `services.account_service.AccountService.send_email_register_email` [bad-argument-type]
   --> controllers/console/auth/email_register.py:78:108
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.get_oauth_client` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:128:23
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:136:23
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:137:21
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.reauthorize_datasource_oauth_provider` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:147:27
+ERROR Argument `Any | None` is not assignable to parameter `credential_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.reauthorize_datasource_oauth_provider` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:153:31
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.add_datasource_oauth_provider` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:157:27
 ERROR Argument `WorkflowRun | None` is not assignable to parameter `workflow_run` with type `WorkflowRun` in function `services.workflow_event_snapshot_service.build_workflow_event_stream` [bad-argument-type]
    --> controllers/console/human_input_form.py:183:42
 ERROR Object of class `NoneType` has no attribute `tenant_id` [missing-attribute]
@@ -32,6 +44,26 @@
   --> controllers/console/setup.py:64:2
 ERROR Object of class `MissingRouter` has no attribute `get` [missing-attribute]
   --> controllers/console/version.py:30:2
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.tools.builtin_tools_manage_service.BuiltinToolManageService.get_oauth_client` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:838:73
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:844:23
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:845:21
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `services.tools.builtin_tools_manage_service.BuiltinToolManageService.add_builtin_tool_provider` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:861:21
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.tools.builtin_tools_manage_service.BuiltinToolManageService.add_builtin_tool_provider` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:862:23
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.trigger.trigger_provider_service.TriggerProviderService.get_oauth_client` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:508:23
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:520:23
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:521:21
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.trigger.trigger_subscription_builder_service.TriggerSubscriptionBuilderService.update_trigger_subscription_builder` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:537:23
+ERROR Argument `Any | None` is not assignable to parameter `subscription_builder_id` with type `str` in function `services.trigger.trigger_subscription_builder_service.TriggerSubscriptionBuilderService.update_trigger_subscription_builder` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:539:37
 ERROR `result` may be uninitialized [unbound-name]
   --> controllers/service_api/app/annotation.py:55:16
 ERROR Argument `WorkflowRun | None` is not assignable to parameter `workflow_run` with type `WorkflowRun` in function `services.workflow_event_snapshot_service.build_workflow_event_stream` [bad-argument-type]
@@ -528,11 +560,11 @@
 ERROR Argument `str | None` is not assignable to parameter `value` with type `SQLCoreOperations[str] | str` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
    --> services/conversation_service.py:131:33
 ERROR `dict[str, bool | dict[str, Any] | str | None]` is not assignable to variable `data_source_info` with type `dict[str, bool | str]` [bad-assignment]
-    --> services/dataset_service.py:2095:56
+    --> services/dataset_service.py:2096:56
 ERROR `dict[str, bool | dict[str, Any] | str | None]` is not assignable to variable `data_source_info` with type `dict[str, bool | str]` [bad-assignment]
-    --> services/dataset_service.py:2607:44
+    --> services/dataset_service.py:2608:44
 ERROR `None` is not assignable to attribute `rules` with type `Never` [bad-assignment]
-    --> services/dataset_service.py:2780:51
+    --> services/dataset_service.py:2781:51
 ERROR Class member `DocumentIndexingTaskProxy.NORMAL_TASK_FUNC` overrides parent class `BatchDocumentIndexingProxy` in an inconsistent manner [bad-override]
   --> services/document_indexing_proxy/document_indexing_task_proxy.py:11:5
 ERROR Class member `DocumentIndexingTaskProxy.PRIORITY_TASK_FUNC` overrides parent class `BatchDocumentIndexingProxy` in an inconsistent manner [bad-override]
@@ -549,8 +581,16 @@
    --> services/external_knowledge_service.py:230:17
 ERROR Returned type `dict[Unknown, Unknown] | None` is not assignable to declared return type `dict[str, Any]` [bad-return]
    --> services/external_knowledge_service.py:232:16
+ERROR Argument `dict[str, Any]` is not assignable to parameter `model_config` with type `AppModelConfigDict` in function `models.model.AppModelConfig.from_model_config_dict` [bad-argument-type]
+   --> services/message_service.py:295:76
+ERROR Could not find name `json` [unknown-name]
+   --> services/model_load_balancing_service.py:414:62
+ERROR Could not find name `json` [unknown-name]
+   --> services/model_load_balancing_service.py:468:42
+ERROR Argument `object | Unknown` is not assignable to parameter `token` with type `str` in function `core.helper.encrypter.decrypt_token` [bad-argument-type]
+   --> services/model_load_balancing_service.py:586:79
 ERROR `handled_tenant_count` was assigned in the current scope before the nonlocal declaration [unknown-name]
-  --> services/plugin/plugin_migration.py:72:34
+  --> services/plugin/plugin_migration.py:82:34
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
    --> services/summary_index_service.py:285:29
 ERROR Object of class `NoneType` has no attribute `summary_index_node_id` [missing-attribute]
@@ -5544,27 +5584,27 @@
 ERROR Argument `None` is not assignable to parameter `credentials` with type `dict[Unknown, Unknown]` in function `services.auth.api_key_auth_base.ApiKeyAuthBase.__init__` [bad-argument-type]
   --> tests/unit_tests/services/auth/test_api_key_auth_base.py:48:35
 ERROR Cannot index into `str` [bad-index]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:128:24
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:129:24
 ERROR Cannot index into `str` [bad-index]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:128:24
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:129:24
 ERROR Cannot index into `str` [bad-index]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:133:16
-ERROR Cannot index into `str` [bad-index]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:133:16
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:134:16
 ERROR Cannot index into `str` [bad-index]
    --> tests/unit_tests/services/auth/test_api_key_auth_service.py:134:16
+ERROR Cannot index into `str` [bad-index]
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:135:16
 ERROR `None` is not subscriptable [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:186:16
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:187:16
 ERROR Cannot set item in `dict[str, dict[str, dict[str, str] | str] | str]` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:271:31
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:272:31
 ERROR Cannot delete item in `str` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:287:13
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:288:13
 ERROR Cannot set item in `str` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:295:9
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:296:9
 ERROR Cannot set item in `str` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:383:9
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:384:9
 ERROR Cannot set item in `dict[str, dict[str, str] | str]` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:383:44
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:384:44
 ERROR No matching overload found for function `_pytest.raises.raises` called with arguments: (tuple[type[ValueError], type[KeyError], type[TypeError], type[AttributeError]]) [no-matching-overload]
    --> tests/unit_tests/services/auth/test_auth_integration.py:142:27
 ERROR No matching overload found for function `_pytest.raises.raises` called with arguments: (tuple[type[HTTPError], type[Exception]]) [no-matching-overload]
@@ -5641,25 +5681,25 @@
 ERROR `in` is not supported between `Literal['is not archived']` and `None` [not-iterable]
   --> tests/unit_tests/services/retention/workflow_run/test_delete_archived_workflow_run.py:91:20
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:612:67
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:613:67
 ERROR `in` is not supported between `Literal['Storage not configured']` and `None` [not-iterable]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:615:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:616:16
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:629:67
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:630:67
 ERROR `in` is not supported between `Literal['Archive bundle not found']` and `None` [not-iterable]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:632:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:633:16
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:652:63
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:653:63
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:708:71
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:709:71
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:734:67
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:735:67
 ERROR `in` is not supported between `Literal['File is not a zip file']` and `None` [not-iterable]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:738:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:739:16
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:758:71
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:759:71
 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:905:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:906:16
 ERROR Argument `None` is not assignable to parameter `name` with type `str` in function `_make_extension` [bad-argument-type]
    --> tests/unit_tests/services/test_api_based_extension_service.py:230:46
 ERROR Argument `None` is not assignable to parameter `api_endpoint` with type `str` in function `_make_extension` [bad-argument-type]

@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-03-19 02:00:17.542363235 +0000
+++ /tmp/pyrefly_pr.txt	2026-03-19 02:00:07.801391661 +0000
@@ -12,6 +12,18 @@
    --> controllers/console/app/site.py:122:5
 ERROR Argument `str | None` is not assignable to parameter `language` with type `str` in function `services.account_service.AccountService.send_email_register_email` [bad-argument-type]
   --> controllers/console/auth/email_register.py:78:108
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.get_oauth_client` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:128:23
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:136:23
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:137:21
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.reauthorize_datasource_oauth_provider` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:147:27
+ERROR Argument `Any | None` is not assignable to parameter `credential_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.reauthorize_datasource_oauth_provider` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:153:31
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.add_datasource_oauth_provider` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:157:27
 ERROR Argument `WorkflowRun | None` is not assignable to parameter `workflow_run` with type `WorkflowRun` in function `services.workflow_event_snapshot_service.build_workflow_event_stream` [bad-argument-type]
    --> controllers/console/human_input_form.py:183:42
 ERROR Object of class `NoneType` has no attribute `tenant_id` [missing-attribute]
@@ -32,6 +44,26 @@
   --> controllers/console/setup.py:64:2
 ERROR Object of class `MissingRouter` has no attribute `get` [missing-attribute]
   --> controllers/console/version.py:30:2
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.tools.builtin_tools_manage_service.BuiltinToolManageService.get_oauth_client` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:838:73
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:844:23
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:845:21
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `services.tools.builtin_tools_manage_service.BuiltinToolManageService.add_builtin_tool_provider` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:861:21
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.tools.builtin_tools_manage_service.BuiltinToolManageService.add_builtin_tool_provider` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:862:23
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.trigger.trigger_provider_service.TriggerProviderService.get_oauth_client` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:508:23
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:520:23
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:521:21
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.trigger.trigger_subscription_builder_service.TriggerSubscriptionBuilderService.update_trigger_subscription_builder` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:537:23
+ERROR Argument `Any | None` is not assignable to parameter `subscription_builder_id` with type `str` in function `services.trigger.trigger_subscription_builder_service.TriggerSubscriptionBuilderService.update_trigger_subscription_builder` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:539:37
 ERROR `result` may be uninitialized [unbound-name]
   --> controllers/service_api/app/annotation.py:55:16
 ERROR Argument `WorkflowRun | None` is not assignable to parameter `workflow_run` with type `WorkflowRun` in function `services.workflow_event_snapshot_service.build_workflow_event_stream` [bad-argument-type]
@@ -516,7 +548,7 @@
 ERROR No matching overload found for function `redis.client.Redis.__init__` called with arguments: (host=int | str | Unknown, port=int | str | Unknown, password=int | str | Unknown | None, db=int, ssl=bool, ssl_ca_certs=str | None, ssl_cert_reqs=Any | None, ssl_certfile=Any | None, ssl_keyfile=Any | None, socket_timeout=Literal[5], socket_connect_timeout=Literal[5], health_check_interval=Literal[30]) [no-matching-overload]
   --> schedule/queue_monitor_task.py:14:21
 ERROR Object of class `Tenant` has no attribute `role` [missing-attribute]
-    --> services/account_service.py:1121:13
+    --> services/account_service.py:1123:13
 ERROR Runtime checkable protocol `Generator` has an unsafe overlap with type `Iterable[bytes]` [unsafe-overlap]
    --> services/audio_service.py:145:41
 ERROR No matching overload found for function `flask.helpers.stream_with_context` called with arguments: (Generator[bytes]) [no-matching-overload]
@@ -528,11 +560,11 @@
 ERROR Argument `str | None` is not assignable to parameter `value` with type `SQLCoreOperations[str] | str` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
    --> services/conversation_service.py:131:33
 ERROR `dict[str, bool | dict[str, Any] | str | None]` is not assignable to variable `data_source_info` with type `dict[str, bool | str]` [bad-assignment]
-    --> services/dataset_service.py:2095:56
+    --> services/dataset_service.py:2098:56
 ERROR `dict[str, bool | dict[str, Any] | str | None]` is not assignable to variable `data_source_info` with type `dict[str, bool | str]` [bad-assignment]
-    --> services/dataset_service.py:2607:44
+    --> services/dataset_service.py:2610:44
 ERROR `None` is not assignable to attribute `rules` with type `Never` [bad-assignment]
-    --> services/dataset_service.py:2780:51
+    --> services/dataset_service.py:2783:51
 ERROR Class member `DocumentIndexingTaskProxy.NORMAL_TASK_FUNC` overrides parent class `BatchDocumentIndexingProxy` in an inconsistent manner [bad-override]
   --> services/document_indexing_proxy/document_indexing_task_proxy.py:11:5
 ERROR Class member `DocumentIndexingTaskProxy.PRIORITY_TASK_FUNC` overrides parent class `BatchDocumentIndexingProxy` in an inconsistent manner [bad-override]
@@ -549,8 +581,16 @@
    --> services/external_knowledge_service.py:230:17
 ERROR Returned type `dict[Unknown, Unknown] | None` is not assignable to declared return type `dict[str, Any]` [bad-return]
    --> services/external_knowledge_service.py:232:16
+ERROR Argument `dict[str, Any]` is not assignable to parameter `model_config` with type `AppModelConfigDict` in function `models.model.AppModelConfig.from_model_config_dict` [bad-argument-type]
+   --> services/message_service.py:297:76
+ERROR Could not find name `json` [unknown-name]
+   --> services/model_load_balancing_service.py:414:62
+ERROR Could not find name `json` [unknown-name]
+   --> services/model_load_balancing_service.py:468:42
+ERROR Argument `object | Unknown` is not assignable to parameter `token` with type `str` in function `core.helper.encrypter.decrypt_token` [bad-argument-type]
+   --> services/model_load_balancing_service.py:586:79
 ERROR `handled_tenant_count` was assigned in the current scope before the nonlocal declaration [unknown-name]
-  --> services/plugin/plugin_migration.py:72:34
+  --> services/plugin/plugin_migration.py:82:34
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
    --> services/summary_index_service.py:285:29
 ERROR Object of class `NoneType` has no attribute `summary_index_node_id` [missing-attribute]
@@ -5544,27 +5584,27 @@
 ERROR Argument `None` is not assignable to parameter `credentials` with type `dict[Unknown, Unknown]` in function `services.auth.api_key_auth_base.ApiKeyAuthBase.__init__` [bad-argument-type]
   --> tests/unit_tests/services/auth/test_api_key_auth_base.py:48:35
 ERROR Cannot index into `str` [bad-index]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:128:24
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:129:24
 ERROR Cannot index into `str` [bad-index]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:128:24
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:129:24
 ERROR Cannot index into `str` [bad-index]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:133:16
-ERROR Cannot index into `str` [bad-index]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:133:16
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:134:16
 ERROR Cannot index into `str` [bad-index]
    --> tests/unit_tests/services/auth/test_api_key_auth_service.py:134:16
+ERROR Cannot index into `str` [bad-index]
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:135:16
 ERROR `None` is not subscriptable [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:186:16
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:187:16
 ERROR Cannot set item in `dict[str, dict[str, dict[str, str] | str] | str]` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:271:31
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:272:31
 ERROR Cannot delete item in `str` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:287:13
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:288:13
 ERROR Cannot set item in `str` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:295:9
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:296:9
 ERROR Cannot set item in `str` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:383:9
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:384:9
 ERROR Cannot set item in `dict[str, dict[str, str] | str]` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:383:44
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:384:44
 ERROR No matching overload found for function `_pytest.raises.raises` called with arguments: (tuple[type[ValueError], type[KeyError], type[TypeError], type[AttributeError]]) [no-matching-overload]
    --> tests/unit_tests/services/auth/test_auth_integration.py:142:27
 ERROR No matching overload found for function `_pytest.raises.raises` called with arguments: (tuple[type[HTTPError], type[Exception]]) [no-matching-overload]
@@ -5641,25 +5681,25 @@
 ERROR `in` is not supported between `Literal['is not archived']` and `None` [not-iterable]
   --> tests/unit_tests/services/retention/workflow_run/test_delete_archived_workflow_run.py:91:20
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:612:67
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:613:67
 ERROR `in` is not supported between `Literal['Storage not configured']` and `None` [not-iterable]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:615:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:616:16
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:629:67
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:630:67
 ERROR `in` is not supported between `Literal['Archive bundle not found']` and `None` [not-iterable]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:632:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:633:16
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:652:63
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:653:63
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:708:71
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:709:71
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:734:67
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:735:67
 ERROR `in` is not supported between `Literal['File is not a zip file']` and `None` [not-iterable]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:738:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:739:16
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:758:71
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:759:71
 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:905:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:906:16
 ERROR Argument `None` is not assignable to parameter `name` with type `str` in function `_make_extension` [bad-argument-type]
    --> tests/unit_tests/services/test_api_based_extension_service.py:230:46
 ERROR Argument `None` is not assignable to parameter `api_endpoint` with type `str` in function `_make_extension` [bad-argument-type]

@fury0928
fury0928 force-pushed the refactor/replace-json-loads-with-pydantic-services branch from a01c7be to 1224ec4 Compare March 19, 2026 03:09
@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-03-19 03:10:51.443396241 +0000
+++ /tmp/pyrefly_pr.txt	2026-03-19 03:10:42.663400740 +0000
@@ -12,6 +12,18 @@
    --> controllers/console/app/site.py:122:5
 ERROR Argument `str | None` is not assignable to parameter `language` with type `str` in function `services.account_service.AccountService.send_email_register_email` [bad-argument-type]
   --> controllers/console/auth/email_register.py:78:108
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.get_oauth_client` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:128:23
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:136:23
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:137:21
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.reauthorize_datasource_oauth_provider` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:147:27
+ERROR Argument `Any | None` is not assignable to parameter `credential_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.reauthorize_datasource_oauth_provider` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:153:31
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.add_datasource_oauth_provider` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:157:27
 ERROR Argument `WorkflowRun | None` is not assignable to parameter `workflow_run` with type `WorkflowRun` in function `services.workflow_event_snapshot_service.build_workflow_event_stream` [bad-argument-type]
    --> controllers/console/human_input_form.py:183:42
 ERROR Object of class `NoneType` has no attribute `tenant_id` [missing-attribute]
@@ -32,6 +44,26 @@
   --> controllers/console/setup.py:64:2
 ERROR Object of class `MissingRouter` has no attribute `get` [missing-attribute]
   --> controllers/console/version.py:30:2
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.tools.builtin_tools_manage_service.BuiltinToolManageService.get_oauth_client` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:838:73
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:844:23
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:845:21
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `services.tools.builtin_tools_manage_service.BuiltinToolManageService.add_builtin_tool_provider` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:861:21
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.tools.builtin_tools_manage_service.BuiltinToolManageService.add_builtin_tool_provider` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:862:23
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.trigger.trigger_provider_service.TriggerProviderService.get_oauth_client` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:508:23
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:520:23
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:521:21
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.trigger.trigger_subscription_builder_service.TriggerSubscriptionBuilderService.update_trigger_subscription_builder` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:537:23
+ERROR Argument `Any | None` is not assignable to parameter `subscription_builder_id` with type `str` in function `services.trigger.trigger_subscription_builder_service.TriggerSubscriptionBuilderService.update_trigger_subscription_builder` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:539:37
 ERROR `result` may be uninitialized [unbound-name]
   --> controllers/service_api/app/annotation.py:55:16
 ERROR Argument `WorkflowRun | None` is not assignable to parameter `workflow_run` with type `WorkflowRun` in function `services.workflow_event_snapshot_service.build_workflow_event_stream` [bad-argument-type]
@@ -516,7 +548,7 @@
 ERROR No matching overload found for function `redis.client.Redis.__init__` called with arguments: (host=int | str | Unknown, port=int | str | Unknown, password=int | str | Unknown | None, db=int, ssl=bool, ssl_ca_certs=str | None, ssl_cert_reqs=Any | None, ssl_certfile=Any | None, ssl_keyfile=Any | None, socket_timeout=Literal[5], socket_connect_timeout=Literal[5], health_check_interval=Literal[30]) [no-matching-overload]
   --> schedule/queue_monitor_task.py:14:21
 ERROR Object of class `Tenant` has no attribute `role` [missing-attribute]
-    --> services/account_service.py:1121:13
+    --> services/account_service.py:1123:13
 ERROR Runtime checkable protocol `Generator` has an unsafe overlap with type `Iterable[bytes]` [unsafe-overlap]
    --> services/audio_service.py:145:41
 ERROR No matching overload found for function `flask.helpers.stream_with_context` called with arguments: (Generator[bytes]) [no-matching-overload]
@@ -528,11 +560,11 @@
 ERROR Argument `str | None` is not assignable to parameter `value` with type `SQLCoreOperations[str] | str` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
    --> services/conversation_service.py:131:33
 ERROR `dict[str, bool | dict[str, Any] | str | None]` is not assignable to variable `data_source_info` with type `dict[str, bool | str]` [bad-assignment]
-    --> services/dataset_service.py:2095:56
+    --> services/dataset_service.py:2098:56
 ERROR `dict[str, bool | dict[str, Any] | str | None]` is not assignable to variable `data_source_info` with type `dict[str, bool | str]` [bad-assignment]
-    --> services/dataset_service.py:2607:44
+    --> services/dataset_service.py:2610:44
 ERROR `None` is not assignable to attribute `rules` with type `Never` [bad-assignment]
-    --> services/dataset_service.py:2780:51
+    --> services/dataset_service.py:2783:51
 ERROR Class member `DocumentIndexingTaskProxy.NORMAL_TASK_FUNC` overrides parent class `BatchDocumentIndexingProxy` in an inconsistent manner [bad-override]
   --> services/document_indexing_proxy/document_indexing_task_proxy.py:11:5
 ERROR Class member `DocumentIndexingTaskProxy.PRIORITY_TASK_FUNC` overrides parent class `BatchDocumentIndexingProxy` in an inconsistent manner [bad-override]
@@ -549,8 +581,16 @@
    --> services/external_knowledge_service.py:230:17
 ERROR Returned type `dict[Unknown, Unknown] | None` is not assignable to declared return type `dict[str, Any]` [bad-return]
    --> services/external_knowledge_service.py:232:16
+ERROR Argument `dict[str, Any]` is not assignable to parameter `model_config` with type `AppModelConfigDict` in function `models.model.AppModelConfig.from_model_config_dict` [bad-argument-type]
+   --> services/message_service.py:297:76
+ERROR Could not find name `json` [unknown-name]
+   --> services/model_load_balancing_service.py:414:62
+ERROR Could not find name `json` [unknown-name]
+   --> services/model_load_balancing_service.py:468:42
+ERROR Argument `object | Unknown` is not assignable to parameter `token` with type `str` in function `core.helper.encrypter.decrypt_token` [bad-argument-type]
+   --> services/model_load_balancing_service.py:586:79
 ERROR `handled_tenant_count` was assigned in the current scope before the nonlocal declaration [unknown-name]
-  --> services/plugin/plugin_migration.py:72:34
+  --> services/plugin/plugin_migration.py:82:34
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
    --> services/summary_index_service.py:285:29
 ERROR Object of class `NoneType` has no attribute `summary_index_node_id` [missing-attribute]
@@ -5544,27 +5584,27 @@
 ERROR Argument `None` is not assignable to parameter `credentials` with type `dict[Unknown, Unknown]` in function `services.auth.api_key_auth_base.ApiKeyAuthBase.__init__` [bad-argument-type]
   --> tests/unit_tests/services/auth/test_api_key_auth_base.py:48:35
 ERROR Cannot index into `str` [bad-index]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:128:24
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:129:24
 ERROR Cannot index into `str` [bad-index]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:128:24
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:129:24
 ERROR Cannot index into `str` [bad-index]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:133:16
-ERROR Cannot index into `str` [bad-index]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:133:16
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:134:16
 ERROR Cannot index into `str` [bad-index]
    --> tests/unit_tests/services/auth/test_api_key_auth_service.py:134:16
+ERROR Cannot index into `str` [bad-index]
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:135:16
 ERROR `None` is not subscriptable [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:186:16
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:187:16
 ERROR Cannot set item in `dict[str, dict[str, dict[str, str] | str] | str]` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:271:31
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:272:31
 ERROR Cannot delete item in `str` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:287:13
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:288:13
 ERROR Cannot set item in `str` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:295:9
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:296:9
 ERROR Cannot set item in `str` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:383:9
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:384:9
 ERROR Cannot set item in `dict[str, dict[str, str] | str]` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:383:44
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:384:44
 ERROR No matching overload found for function `_pytest.raises.raises` called with arguments: (tuple[type[ValueError], type[KeyError], type[TypeError], type[AttributeError]]) [no-matching-overload]
    --> tests/unit_tests/services/auth/test_auth_integration.py:142:27
 ERROR No matching overload found for function `_pytest.raises.raises` called with arguments: (tuple[type[HTTPError], type[Exception]]) [no-matching-overload]
@@ -5641,25 +5681,25 @@
 ERROR `in` is not supported between `Literal['is not archived']` and `None` [not-iterable]
   --> tests/unit_tests/services/retention/workflow_run/test_delete_archived_workflow_run.py:91:20
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:612:67
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:613:67
 ERROR `in` is not supported between `Literal['Storage not configured']` and `None` [not-iterable]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:615:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:616:16
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:629:67
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:630:67
 ERROR `in` is not supported between `Literal['Archive bundle not found']` and `None` [not-iterable]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:632:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:633:16
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:652:63
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:653:63
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:708:71
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:709:71
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:734:67
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:735:67
 ERROR `in` is not supported between `Literal['File is not a zip file']` and `None` [not-iterable]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:738:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:739:16
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:758:71
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:759:71
 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:905:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:906:16
 ERROR Argument `None` is not assignable to parameter `name` with type `str` in function `_make_extension` [bad-argument-type]
    --> tests/unit_tests/services/test_api_based_extension_service.py:230:46
 ERROR Argument `None` is not assignable to parameter `api_endpoint` with type `str` in function `_make_extension` [bad-argument-type]

@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-03-19 03:14:37.982366312 +0000
+++ /tmp/pyrefly_pr.txt	2026-03-19 03:14:27.902388662 +0000
@@ -12,6 +12,18 @@
    --> controllers/console/app/site.py:122:5
 ERROR Argument `str | None` is not assignable to parameter `language` with type `str` in function `services.account_service.AccountService.send_email_register_email` [bad-argument-type]
   --> controllers/console/auth/email_register.py:78:108
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.get_oauth_client` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:128:23
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:136:23
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:137:21
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.reauthorize_datasource_oauth_provider` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:147:27
+ERROR Argument `Any | None` is not assignable to parameter `credential_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.reauthorize_datasource_oauth_provider` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:153:31
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.add_datasource_oauth_provider` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:157:27
 ERROR Argument `WorkflowRun | None` is not assignable to parameter `workflow_run` with type `WorkflowRun` in function `services.workflow_event_snapshot_service.build_workflow_event_stream` [bad-argument-type]
    --> controllers/console/human_input_form.py:183:42
 ERROR Object of class `NoneType` has no attribute `tenant_id` [missing-attribute]
@@ -32,6 +44,26 @@
   --> controllers/console/setup.py:64:2
 ERROR Object of class `MissingRouter` has no attribute `get` [missing-attribute]
   --> controllers/console/version.py:30:2
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.tools.builtin_tools_manage_service.BuiltinToolManageService.get_oauth_client` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:838:73
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:844:23
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:845:21
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `services.tools.builtin_tools_manage_service.BuiltinToolManageService.add_builtin_tool_provider` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:861:21
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.tools.builtin_tools_manage_service.BuiltinToolManageService.add_builtin_tool_provider` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:862:23
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.trigger.trigger_provider_service.TriggerProviderService.get_oauth_client` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:508:23
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:520:23
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:521:21
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.trigger.trigger_subscription_builder_service.TriggerSubscriptionBuilderService.update_trigger_subscription_builder` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:537:23
+ERROR Argument `Any | None` is not assignable to parameter `subscription_builder_id` with type `str` in function `services.trigger.trigger_subscription_builder_service.TriggerSubscriptionBuilderService.update_trigger_subscription_builder` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:539:37
 ERROR `result` may be uninitialized [unbound-name]
   --> controllers/service_api/app/annotation.py:55:16
 ERROR Argument `WorkflowRun | None` is not assignable to parameter `workflow_run` with type `WorkflowRun` in function `services.workflow_event_snapshot_service.build_workflow_event_stream` [bad-argument-type]
@@ -516,7 +548,7 @@
 ERROR No matching overload found for function `redis.client.Redis.__init__` called with arguments: (host=int | str | Unknown, port=int | str | Unknown, password=int | str | Unknown | None, db=int, ssl=bool, ssl_ca_certs=str | None, ssl_cert_reqs=Any | None, ssl_certfile=Any | None, ssl_keyfile=Any | None, socket_timeout=Literal[5], socket_connect_timeout=Literal[5], health_check_interval=Literal[30]) [no-matching-overload]
   --> schedule/queue_monitor_task.py:14:21
 ERROR Object of class `Tenant` has no attribute `role` [missing-attribute]
-    --> services/account_service.py:1121:13
+    --> services/account_service.py:1123:13
 ERROR Runtime checkable protocol `Generator` has an unsafe overlap with type `Iterable[bytes]` [unsafe-overlap]
    --> services/audio_service.py:145:41
 ERROR No matching overload found for function `flask.helpers.stream_with_context` called with arguments: (Generator[bytes]) [no-matching-overload]
@@ -528,11 +560,11 @@
 ERROR Argument `str | None` is not assignable to parameter `value` with type `SQLCoreOperations[str] | str` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
    --> services/conversation_service.py:131:33
 ERROR `dict[str, bool | dict[str, Any] | str | None]` is not assignable to variable `data_source_info` with type `dict[str, bool | str]` [bad-assignment]
-    --> services/dataset_service.py:2095:56
+    --> services/dataset_service.py:2098:56
 ERROR `dict[str, bool | dict[str, Any] | str | None]` is not assignable to variable `data_source_info` with type `dict[str, bool | str]` [bad-assignment]
-    --> services/dataset_service.py:2607:44
+    --> services/dataset_service.py:2610:44
 ERROR `None` is not assignable to attribute `rules` with type `Never` [bad-assignment]
-    --> services/dataset_service.py:2780:51
+    --> services/dataset_service.py:2783:51
 ERROR Class member `DocumentIndexingTaskProxy.NORMAL_TASK_FUNC` overrides parent class `BatchDocumentIndexingProxy` in an inconsistent manner [bad-override]
   --> services/document_indexing_proxy/document_indexing_task_proxy.py:11:5
 ERROR Class member `DocumentIndexingTaskProxy.PRIORITY_TASK_FUNC` overrides parent class `BatchDocumentIndexingProxy` in an inconsistent manner [bad-override]
@@ -550,7 +582,7 @@
 ERROR Returned type `dict[Unknown, Unknown] | None` is not assignable to declared return type `dict[str, Any]` [bad-return]
    --> services/external_knowledge_service.py:232:16
 ERROR `handled_tenant_count` was assigned in the current scope before the nonlocal declaration [unknown-name]
-  --> services/plugin/plugin_migration.py:72:34
+  --> services/plugin/plugin_migration.py:82:34
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
    --> services/summary_index_service.py:285:29
 ERROR Object of class `NoneType` has no attribute `summary_index_node_id` [missing-attribute]
@@ -5544,27 +5576,27 @@
 ERROR Argument `None` is not assignable to parameter `credentials` with type `dict[Unknown, Unknown]` in function `services.auth.api_key_auth_base.ApiKeyAuthBase.__init__` [bad-argument-type]
   --> tests/unit_tests/services/auth/test_api_key_auth_base.py:48:35
 ERROR Cannot index into `str` [bad-index]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:128:24
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:129:24
 ERROR Cannot index into `str` [bad-index]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:128:24
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:129:24
 ERROR Cannot index into `str` [bad-index]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:133:16
-ERROR Cannot index into `str` [bad-index]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:133:16
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:134:16
 ERROR Cannot index into `str` [bad-index]
    --> tests/unit_tests/services/auth/test_api_key_auth_service.py:134:16
+ERROR Cannot index into `str` [bad-index]
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:135:16
 ERROR `None` is not subscriptable [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:186:16
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:187:16
 ERROR Cannot set item in `dict[str, dict[str, dict[str, str] | str] | str]` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:271:31
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:272:31
 ERROR Cannot delete item in `str` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:287:13
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:288:13
 ERROR Cannot set item in `str` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:295:9
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:296:9
 ERROR Cannot set item in `str` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:383:9
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:384:9
 ERROR Cannot set item in `dict[str, dict[str, str] | str]` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:383:44
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:384:44
 ERROR No matching overload found for function `_pytest.raises.raises` called with arguments: (tuple[type[ValueError], type[KeyError], type[TypeError], type[AttributeError]]) [no-matching-overload]
    --> tests/unit_tests/services/auth/test_auth_integration.py:142:27
 ERROR No matching overload found for function `_pytest.raises.raises` called with arguments: (tuple[type[HTTPError], type[Exception]]) [no-matching-overload]
@@ -5641,25 +5673,25 @@
 ERROR `in` is not supported between `Literal['is not archived']` and `None` [not-iterable]
   --> tests/unit_tests/services/retention/workflow_run/test_delete_archived_workflow_run.py:91:20
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:612:67
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:613:67
 ERROR `in` is not supported between `Literal['Storage not configured']` and `None` [not-iterable]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:615:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:616:16
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:629:67
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:630:67
 ERROR `in` is not supported between `Literal['Archive bundle not found']` and `None` [not-iterable]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:632:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:633:16
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:652:63
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:653:63
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:708:71
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:709:71
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:734:67
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:735:67
 ERROR `in` is not supported between `Literal['File is not a zip file']` and `None` [not-iterable]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:738:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:739:16
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:758:71
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:759:71
 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:905:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:906:16
 ERROR Argument `None` is not assignable to parameter `name` with type `str` in function `_make_extension` [bad-argument-type]
    --> tests/unit_tests/services/test_api_based_extension_service.py:230:46
 ERROR Argument `None` is not assignable to parameter `api_endpoint` with type `str` in function `_make_extension` [bad-argument-type]

@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-03-19 03:53:41.559589426 +0000
+++ /tmp/pyrefly_pr.txt	2026-03-19 03:53:32.597503495 +0000
@@ -12,6 +12,18 @@
    --> controllers/console/app/site.py:122:5
 ERROR Argument `str | None` is not assignable to parameter `language` with type `str` in function `services.account_service.AccountService.send_email_register_email` [bad-argument-type]
   --> controllers/console/auth/email_register.py:78:108
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.get_oauth_client` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:128:23
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:136:23
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:137:21
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.reauthorize_datasource_oauth_provider` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:147:27
+ERROR Argument `Any | None` is not assignable to parameter `credential_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.reauthorize_datasource_oauth_provider` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:153:31
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.datasource_provider_service.DatasourceProviderService.add_datasource_oauth_provider` [bad-argument-type]
+   --> controllers/console/datasets/rag_pipeline/datasource_auth.py:157:27
 ERROR Argument `WorkflowRun | None` is not assignable to parameter `workflow_run` with type `WorkflowRun` in function `services.workflow_event_snapshot_service.build_workflow_event_stream` [bad-argument-type]
    --> controllers/console/human_input_form.py:183:42
 ERROR Object of class `NoneType` has no attribute `tenant_id` [missing-attribute]
@@ -32,6 +44,26 @@
   --> controllers/console/setup.py:64:2
 ERROR Object of class `MissingRouter` has no attribute `get` [missing-attribute]
   --> controllers/console/version.py:30:2
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.tools.builtin_tools_manage_service.BuiltinToolManageService.get_oauth_client` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:838:73
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:844:23
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:845:21
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `services.tools.builtin_tools_manage_service.BuiltinToolManageService.add_builtin_tool_provider` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:861:21
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.tools.builtin_tools_manage_service.BuiltinToolManageService.add_builtin_tool_provider` [bad-argument-type]
+   --> controllers/console/workspace/tool_providers.py:862:23
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.trigger.trigger_provider_service.TriggerProviderService.get_oauth_client` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:508:23
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:520:23
+ERROR Argument `Any | None` is not assignable to parameter `user_id` with type `str` in function `core.plugin.impl.oauth.OAuthHandler.get_credentials` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:521:21
+ERROR Argument `Any | None` is not assignable to parameter `tenant_id` with type `str` in function `services.trigger.trigger_subscription_builder_service.TriggerSubscriptionBuilderService.update_trigger_subscription_builder` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:537:23
+ERROR Argument `Any | None` is not assignable to parameter `subscription_builder_id` with type `str` in function `services.trigger.trigger_subscription_builder_service.TriggerSubscriptionBuilderService.update_trigger_subscription_builder` [bad-argument-type]
+   --> controllers/console/workspace/trigger_providers.py:539:37
 ERROR `result` may be uninitialized [unbound-name]
   --> controllers/service_api/app/annotation.py:55:16
 ERROR Argument `WorkflowRun | None` is not assignable to parameter `workflow_run` with type `WorkflowRun` in function `services.workflow_event_snapshot_service.build_workflow_event_stream` [bad-argument-type]
@@ -516,7 +548,7 @@
 ERROR No matching overload found for function `redis.client.Redis.__init__` called with arguments: (host=int | str | Unknown, port=int | str | Unknown, password=int | str | Unknown | None, db=int, ssl=bool, ssl_ca_certs=str | None, ssl_cert_reqs=Any | None, ssl_certfile=Any | None, ssl_keyfile=Any | None, socket_timeout=Literal[5], socket_connect_timeout=Literal[5], health_check_interval=Literal[30]) [no-matching-overload]
   --> schedule/queue_monitor_task.py:14:21
 ERROR Object of class `Tenant` has no attribute `role` [missing-attribute]
-    --> services/account_service.py:1121:13
+    --> services/account_service.py:1123:13
 ERROR Runtime checkable protocol `Generator` has an unsafe overlap with type `Iterable[bytes]` [unsafe-overlap]
    --> services/audio_service.py:145:41
 ERROR No matching overload found for function `flask.helpers.stream_with_context` called with arguments: (Generator[bytes]) [no-matching-overload]
@@ -528,11 +560,11 @@
 ERROR Argument `str | None` is not assignable to parameter `value` with type `SQLCoreOperations[str] | str` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
    --> services/conversation_service.py:131:33
 ERROR `dict[str, bool | dict[str, Any] | str | None]` is not assignable to variable `data_source_info` with type `dict[str, bool | str]` [bad-assignment]
-    --> services/dataset_service.py:2095:56
+    --> services/dataset_service.py:2098:56
 ERROR `dict[str, bool | dict[str, Any] | str | None]` is not assignable to variable `data_source_info` with type `dict[str, bool | str]` [bad-assignment]
-    --> services/dataset_service.py:2607:44
+    --> services/dataset_service.py:2610:44
 ERROR `None` is not assignable to attribute `rules` with type `Never` [bad-assignment]
-    --> services/dataset_service.py:2780:51
+    --> services/dataset_service.py:2783:51
 ERROR Class member `DocumentIndexingTaskProxy.NORMAL_TASK_FUNC` overrides parent class `BatchDocumentIndexingProxy` in an inconsistent manner [bad-override]
   --> services/document_indexing_proxy/document_indexing_task_proxy.py:11:5
 ERROR Class member `DocumentIndexingTaskProxy.PRIORITY_TASK_FUNC` overrides parent class `BatchDocumentIndexingProxy` in an inconsistent manner [bad-override]
@@ -550,7 +582,7 @@
 ERROR Returned type `dict[Unknown, Unknown] | None` is not assignable to declared return type `dict[str, Any]` [bad-return]
    --> services/external_knowledge_service.py:232:16
 ERROR `handled_tenant_count` was assigned in the current scope before the nonlocal declaration [unknown-name]
-  --> services/plugin/plugin_migration.py:72:34
+  --> services/plugin/plugin_migration.py:82:34
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
    --> services/summary_index_service.py:285:29
 ERROR Object of class `NoneType` has no attribute `summary_index_node_id` [missing-attribute]
@@ -5544,27 +5576,27 @@
 ERROR Argument `None` is not assignable to parameter `credentials` with type `dict[Unknown, Unknown]` in function `services.auth.api_key_auth_base.ApiKeyAuthBase.__init__` [bad-argument-type]
   --> tests/unit_tests/services/auth/test_api_key_auth_base.py:48:35
 ERROR Cannot index into `str` [bad-index]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:128:24
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:129:24
 ERROR Cannot index into `str` [bad-index]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:128:24
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:129:24
 ERROR Cannot index into `str` [bad-index]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:133:16
-ERROR Cannot index into `str` [bad-index]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:133:16
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:134:16
 ERROR Cannot index into `str` [bad-index]
    --> tests/unit_tests/services/auth/test_api_key_auth_service.py:134:16
+ERROR Cannot index into `str` [bad-index]
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:135:16
 ERROR `None` is not subscriptable [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:186:16
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:187:16
 ERROR Cannot set item in `dict[str, dict[str, dict[str, str] | str] | str]` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:271:31
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:272:31
 ERROR Cannot delete item in `str` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:287:13
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:288:13
 ERROR Cannot set item in `str` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:295:9
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:296:9
 ERROR Cannot set item in `str` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:383:9
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:384:9
 ERROR Cannot set item in `dict[str, dict[str, str] | str]` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:383:44
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:384:44
 ERROR No matching overload found for function `_pytest.raises.raises` called with arguments: (tuple[type[ValueError], type[KeyError], type[TypeError], type[AttributeError]]) [no-matching-overload]
    --> tests/unit_tests/services/auth/test_auth_integration.py:142:27
 ERROR No matching overload found for function `_pytest.raises.raises` called with arguments: (tuple[type[HTTPError], type[Exception]]) [no-matching-overload]
@@ -5641,25 +5673,25 @@
 ERROR `in` is not supported between `Literal['is not archived']` and `None` [not-iterable]
   --> tests/unit_tests/services/retention/workflow_run/test_delete_archived_workflow_run.py:91:20
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:612:67
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:613:67
 ERROR `in` is not supported between `Literal['Storage not configured']` and `None` [not-iterable]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:615:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:616:16
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:629:67
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:630:67
 ERROR `in` is not supported between `Literal['Archive bundle not found']` and `None` [not-iterable]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:632:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:633:16
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:652:63
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:653:63
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:708:71
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:709:71
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:734:67
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:735:67
 ERROR `in` is not supported between `Literal['File is not a zip file']` and `None` [not-iterable]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:738:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:739:16
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:758:71
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:759:71
 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:905:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:906:16
 ERROR Argument `None` is not assignable to parameter `name` with type `str` in function `_make_extension` [bad-argument-type]
    --> tests/unit_tests/services/test_api_based_extension_service.py:230:46
 ERROR Argument `None` is not assignable to parameter `api_endpoint` with type `str` in function `_make_extension` [bad-argument-type]

@fury0928

Copy link
Copy Markdown
Contributor Author

@asukaminato0721 would you review this PR? I am not sure why this fails always

@asukaminato0721

Copy link
Copy Markdown
Contributor
/home/runner/work/dify/dify/api/controllers/console/datasets/rag_pipeline/datasource_auth.py:128:23 - error: Argument of type "Any | None" cannot be assigned to parameter "tenant_id" of type "str" in function "get_oauth_client"
  Type "Any | None" is not assignable to type "str"
    "None" is not assignable to "str" (reportArgumentType)
Error: Argument of type "Any | None" cannot be assigned to parameter "tenant_id" of type "str" in function "get_oauth_client"
  Type "Any | None" is not assignable to type "str"
    "None" is not assignable to "str" (reportArgumentType)
/home/runner/work/dify/dify/api/controllers/console/datasets/rag_pipeline/datasource_auth.py:136:23 - error: Argument of type "Any | None" cannot be assigned to parameter "tenant_id" of type "str" in function "get_credentials"
  Type "Any | None" is not assignable to type "str"
    "None" is not assignable to "str" (reportArgumentType)
Error: Argument of type "Any | None" cannot be assigned to parameter "tenant_id" of type "str" in function "get_credentials"
  Type "Any | None" is not assignable to type "str"
    "None" is not assignable to "str" (reportArgumentType)
/home/runner/work/dify/dify/api/controllers/console/datasets/rag_pipeline/datasource_auth.py:137:21 - error: Argument of type "Any | None" cannot be assigned to parameter "user_id" of type "str" in function "get_credentials"
  Type "Any | None" is not assignable to type "str"
    "None" is not assignable to "str" (reportArgumentType)
Error: Argument of type "Any | None" cannot be assigned to parameter "user_id" of type "str" in function "get_credentials"
  Type "Any | None" is not assignable to type "str"
    "None" is not assignable to "str" (reportArgumentType)
/home/runner/work/dify/dify/api/controllers/console/datasets/rag_pipeline/datasource_auth.py:147:27 - error: Argument of type "Any | None" cannot be assigned to parameter "tenant_id" of type "str" in function "reauthorize_datasource_oauth_provider"
  Type "Any | None" is not assignable to type "str"
    "None" is not assignable to "str" (reportArgumentType)
Error: Argument of type "Any | None" cannot be assigned to parameter "tenant_id" of type "str" in function "reauthorize_datasource_oauth_provider"
  Type "Any | None" is not assignable to type "str"
    "None" is not assignable to "str" (reportArgumentType)
/home/runner/work/dify/dify/api/controllers/console/datasets/rag_pipeline/datasource_auth.py:153:31 - error: Argument of type "Any | None" cannot be assigned to parameter "credential_id" of type "str" in function "reauthorize_datasource_oauth_provider"
  Type "Any | None" is not assignable to type "str"
    "None" is not assignable to "str" (reportArgumentType)
Error: Argument of type "Any | None" cannot be assigned to parameter "credential_id" of type "str" in function "reauthorize_datasource_oauth_provider"
  Type "Any | None" is not assignable to type "str"
    "None" is not assignable to "str" (reportArgumentType)
/home/runner/work/dify/dify/api/controllers/console/datasets/rag_pipeline/datasource_auth.py:157:27 - error: Argument of type "Any | None" cannot be assigned to parameter "tenant_id" of type "str" in function "add_datasource_oauth_provider"
  Type "Any | None" is not assignable to type "str"
    "None" is not assignable to "str" (reportArgumentType)
Error: Argument of type "Any | None" cannot be assigned to parameter "tenant_id" of type "str" in function "add_datasource_oauth_provider"
  Type "Any | None" is not assignable to type "str"
    "None" is not assignable to "str" (reportArgumentType)
/home/runner/work/dify/dify/api/controllers/console/workspace/tool_providers.py:838:73 - error: Argument of type "Any | None" cannot be assigned to parameter "tenant_id" of type "str" in function "get_oauth_client"
  Type "Any | None" is not assignable to type "str"
    "None" is not assignable to "str" (reportArgumentType)
Error: Argument of type "Any | None" cannot be assigned to parameter "tenant_id" of type "str" in function "get_oauth_client"
  Type "Any | None" is not assignable to type "str"
    "None" is not assignable to "str" (reportArgumentType)
/home/runner/work/dify/dify/api/controllers/console/workspace/tool_providers.py:844:23 - error: Argument of type "Any | None" cannot be assigned to parameter "tenant_id" of type "str" in function "get_credentials"
  Type "Any | None" is not assignable to type "str"
    "None" is not assignable to "str" (reportArgumentType)
Error: Argument of type "Any | None" cannot be assigned to parameter "tenant_id" of type "str" in function "get_credentials"
  Type "Any | None" is not assignable to type "str"
    "None" is not assignable to "str" (reportArgumentType)
/home/runner/work/dify/dify/api/controllers/console/workspace/tool_providers.py:845:21 - error: Argument of type "Any | None" cannot be assigned to parameter "user_id" of type "str" in function "get_credentials"
  Type "Any | None" is not assignable to type "str"
    "None" is not assignable to "str" (reportArgumentType)
Error: Argument of type "Any | None" cannot be assigned to parameter "user_id" of type "str" in function "get_credentials"
  Type "Any | None" is not assignable to type "str"
    "None" is not assignable to "str" (reportArgumentType)
/home/runner/work/dify/dify/api/controllers/console/workspace/tool_providers.py:861:21 - error: Argument of type "Any | None" cannot be assigned to parameter "user_id" of type "str" in function "add_builtin_tool_provider"
  Type "Any | None" is not assignable to type "str"
    "None" is not assignable to "str" (reportArgumentType)
Error: Argument of type "Any | None" cannot be assigned to parameter "user_id" of type "str" in function "add_builtin_tool_provider"
  Type "Any | None" is not assignable to type "str"
    "None" is not assignable to "str" (reportArgumentType)
/home/runner/work/dify/dify/api/controllers/console/workspace/tool_providers.py:862:23 - error: Argument of type "Any | None" cannot be assigned to parameter "tenant_id" of type "str" in function "add_builtin_tool_provider"
  Type "Any | None" is not assignable to type "str"
    "None" is not assignable to "str" (reportArgumentType)
Error: Argument of type "Any | None" cannot be assigned to parameter "tenant_id" of type "str" in function "add_builtin_tool_provider"
  Type "Any | None" is not assignable to type "str"
    "None" is not assignable to "str" (reportArgumentType)
/home/runner/work/dify/dify/api/controllers/console/workspace/trigger_providers.py:508:23 - error: Argument of type "Any | None" cannot be assigned to parameter "tenant_id" of type "str" in function "get_oauth_client"
  Type "Any | None" is not assignable to type "str"
    "None" is not assignable to "str" (reportArgumentType)
Error: Argument of type "Any | None" cannot be assigned to parameter "tenant_id" of type "str" in function "get_oauth_client"
  Type "Any | None" is not assignable to type "str"
    "None" is not assignable to "str" (reportArgumentType)
/home/runner/work/dify/dify/api/controllers/console/workspace/trigger_providers.py:520:23 - error: Argument of type "Any | None" cannot be assigned to parameter "tenant_id" of type "str" in function "get_credentials"
  Type "Any | None" is not assignable to type "str"
    "None" is not assignable to "str" (reportArgumentType)
Error: Argument of type "Any | None" cannot be assigned to parameter "tenant_id" of type "str" in function "get_credentials"
  Type "Any | None" is not assignable to type "str"
    "None" is not assignable to "str" (reportArgumentType)
/home/runner/work/dify/dify/api/controllers/console/workspace/trigger_providers.py:521:21 - error: Argument of type "Any | None" cannot be assigned to parameter "user_id" of type "str" in function "get_credentials"
  Type "Any | None" is not assignable to type "str"
    "None" is not assignable to "str" (reportArgumentType)
Error: Argument of type "Any | None" cannot be assigned to parameter "user_id" of type "str" in function "get_credentials"
  Type "Any | None" is not assignable to type "str"
    "None" is not assignable to "str" (reportArgumentType)
/home/runner/work/dify/dify/api/controllers/console/workspace/trigger_providers.py:537:23 - error: Argument of type "Any | None" cannot be assigned to parameter "tenant_id" of type "str" in function "update_trigger_subscription_builder"
  Type "Any | None" is not assignable to type "str"
    "None" is not assignable to "str" (reportArgumentType)
Error: Argument of type "Any | None" cannot be assigned to parameter "tenant_id" of type "str" in function "update_trigger_subscription_builder"
  Type "Any | None" is not assignable to type "str"
    "None" is not assignable to "str" (reportArgumentType)
/home/runner/work/dify/dify/api/controllers/console/workspace/trigger_providers.py:539:37 - error: Argument of type "Any | None" cannot be assigned to parameter "subscription_builder_id" of type "str" in function "update_trigger_subscription_builder"
  Type "Any | None" is not assignable to type "str"
    "None" is not assignable to "str" (reportArgumentType)
Error: Argument of type "Any | None" cannot be assigned to parameter "subscription_builder_id" of type "str" in function "update_trigger_subscription_builder"
  Type "Any | None" is not assignable to type "str"
    "None" is not assignable to "str" (reportArgumentType)
Error: 16 errors

@dosu @gemini-code-assist how to fix this

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@dosubot

dosubot Bot commented Mar 19, 2026

Copy link
Copy Markdown

These type errors occur because values like tenant_id, user_id, and credential_id are retrieved from context dictionaries using .get(), which returns Any | None, but the service methods expect str.

Fix: Add assert statements before passing these values to service methods. This is the established pattern in the Dify codebase for type narrowing.

For datasource_auth.py (around lines 123-157), add assertions after retrieving from context:

user_id = context.get("user_id")
tenant_id = context.get("tenant_id")
credential_id = context.get("credential_id")

assert tenant_id is not None
assert user_id is not None
# Add assert for credential_id where needed

For tool_providers.py (around lines 838-862) and trigger_providers.py (around lines 508-539), apply the same pattern.

This matches existing patterns in the codebase, such as trigger_providers.py line 558 and workflow_trigger.py, where assertions are used to narrow types before calling service methods.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor  Share on X

@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-03-19 10:20:42.216328908 +0000
+++ /tmp/pyrefly_pr.txt	2026-03-19 10:20:32.922297144 +0000
@@ -516,7 +516,7 @@
 ERROR No matching overload found for function `redis.client.Redis.__init__` called with arguments: (host=int | str | Unknown, port=int | str | Unknown, password=int | str | Unknown | None, db=int, ssl=bool, ssl_ca_certs=str | None, ssl_cert_reqs=Any | None, ssl_certfile=Any | None, ssl_keyfile=Any | None, socket_timeout=Literal[5], socket_connect_timeout=Literal[5], health_check_interval=Literal[30]) [no-matching-overload]
   --> schedule/queue_monitor_task.py:14:21
 ERROR Object of class `Tenant` has no attribute `role` [missing-attribute]
-    --> services/account_service.py:1121:13
+    --> services/account_service.py:1123:13
 ERROR Runtime checkable protocol `Generator` has an unsafe overlap with type `Iterable[bytes]` [unsafe-overlap]
    --> services/audio_service.py:145:41
 ERROR No matching overload found for function `flask.helpers.stream_with_context` called with arguments: (Generator[bytes]) [no-matching-overload]
@@ -528,11 +528,11 @@
 ERROR Argument `str | None` is not assignable to parameter `value` with type `SQLCoreOperations[str] | str` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
    --> services/conversation_service.py:131:33
 ERROR `dict[str, bool | dict[str, Any] | str | None]` is not assignable to variable `data_source_info` with type `dict[str, bool | str]` [bad-assignment]
-    --> services/dataset_service.py:2095:56
+    --> services/dataset_service.py:2098:56
 ERROR `dict[str, bool | dict[str, Any] | str | None]` is not assignable to variable `data_source_info` with type `dict[str, bool | str]` [bad-assignment]
-    --> services/dataset_service.py:2607:44
+    --> services/dataset_service.py:2610:44
 ERROR `None` is not assignable to attribute `rules` with type `Never` [bad-assignment]
-    --> services/dataset_service.py:2780:51
+    --> services/dataset_service.py:2783:51
 ERROR Class member `DocumentIndexingTaskProxy.NORMAL_TASK_FUNC` overrides parent class `BatchDocumentIndexingProxy` in an inconsistent manner [bad-override]
   --> services/document_indexing_proxy/document_indexing_task_proxy.py:11:5
 ERROR Class member `DocumentIndexingTaskProxy.PRIORITY_TASK_FUNC` overrides parent class `BatchDocumentIndexingProxy` in an inconsistent manner [bad-override]
@@ -550,7 +550,7 @@
 ERROR Returned type `dict[Unknown, Unknown] | None` is not assignable to declared return type `dict[str, Any]` [bad-return]
    --> services/external_knowledge_service.py:232:16
 ERROR `handled_tenant_count` was assigned in the current scope before the nonlocal declaration [unknown-name]
-  --> services/plugin/plugin_migration.py:72:34
+  --> services/plugin/plugin_migration.py:82:34
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
    --> services/summary_index_service.py:285:29
 ERROR Object of class `NoneType` has no attribute `summary_index_node_id` [missing-attribute]
@@ -5554,27 +5554,27 @@
 ERROR Argument `None` is not assignable to parameter `credentials` with type `dict[Unknown, Unknown]` in function `services.auth.api_key_auth_base.ApiKeyAuthBase.__init__` [bad-argument-type]
   --> tests/unit_tests/services/auth/test_api_key_auth_base.py:48:35
 ERROR Cannot index into `str` [bad-index]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:128:24
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:129:24
 ERROR Cannot index into `str` [bad-index]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:128:24
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:129:24
 ERROR Cannot index into `str` [bad-index]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:133:16
-ERROR Cannot index into `str` [bad-index]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:133:16
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:134:16
 ERROR Cannot index into `str` [bad-index]
    --> tests/unit_tests/services/auth/test_api_key_auth_service.py:134:16
+ERROR Cannot index into `str` [bad-index]
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:135:16
 ERROR `None` is not subscriptable [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:186:16
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:187:16
 ERROR Cannot set item in `dict[str, dict[str, dict[str, str] | str] | str]` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:271:31
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:272:31
 ERROR Cannot delete item in `str` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:287:13
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:288:13
 ERROR Cannot set item in `str` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:295:9
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:296:9
 ERROR Cannot set item in `str` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:383:9
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:384:9
 ERROR Cannot set item in `dict[str, dict[str, str] | str]` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:383:44
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:384:44
 ERROR No matching overload found for function `_pytest.raises.raises` called with arguments: (tuple[type[ValueError], type[KeyError], type[TypeError], type[AttributeError]]) [no-matching-overload]
    --> tests/unit_tests/services/auth/test_auth_integration.py:142:27
 ERROR No matching overload found for function `_pytest.raises.raises` called with arguments: (tuple[type[HTTPError], type[Exception]]) [no-matching-overload]
@@ -5651,25 +5651,25 @@
 ERROR `in` is not supported between `Literal['is not archived']` and `None` [not-iterable]
   --> tests/unit_tests/services/retention/workflow_run/test_delete_archived_workflow_run.py:91:20
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:612:67
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:613:67
 ERROR `in` is not supported between `Literal['Storage not configured']` and `None` [not-iterable]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:615:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:616:16
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:629:67
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:630:67
 ERROR `in` is not supported between `Literal['Archive bundle not found']` and `None` [not-iterable]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:632:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:633:16
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:652:63
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:653:63
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:708:71
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:709:71
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:734:67
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:735:67
 ERROR `in` is not supported between `Literal['File is not a zip file']` and `None` [not-iterable]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:738:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:739:16
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:758:71
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:759:71
 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:905:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:906:16
 ERROR Argument `None` is not assignable to parameter `name` with type `str` in function `_make_extension` [bad-argument-type]
    --> tests/unit_tests/services/test_api_based_extension_service.py:230:46
 ERROR Argument `None` is not assignable to parameter `api_endpoint` with type `str` in function `_make_extension` [bad-argument-type]

@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-03-19 18:12:40.533290341 +0000
+++ /tmp/pyrefly_pr.txt	2026-03-19 18:12:30.418158170 +0000
@@ -516,7 +516,7 @@
 ERROR No matching overload found for function `redis.client.Redis.__init__` called with arguments: (host=int | str | Unknown, port=int | str | Unknown, password=int | str | Unknown | None, db=int, ssl=bool, ssl_ca_certs=str | None, ssl_cert_reqs=Any | None, ssl_certfile=Any | None, ssl_keyfile=Any | None, socket_timeout=Literal[5], socket_connect_timeout=Literal[5], health_check_interval=Literal[30]) [no-matching-overload]
   --> schedule/queue_monitor_task.py:14:21
 ERROR Object of class `Tenant` has no attribute `role` [missing-attribute]
-    --> services/account_service.py:1121:13
+    --> services/account_service.py:1123:13
 ERROR Runtime checkable protocol `Generator` has an unsafe overlap with type `Iterable[bytes]` [unsafe-overlap]
    --> services/audio_service.py:145:41
 ERROR No matching overload found for function `flask.helpers.stream_with_context` called with arguments: (Generator[bytes]) [no-matching-overload]
@@ -528,11 +528,11 @@
 ERROR Argument `str | None` is not assignable to parameter `value` with type `SQLCoreOperations[str] | str` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
    --> services/conversation_service.py:131:33
 ERROR `dict[str, bool | dict[str, Any] | str | None]` is not assignable to variable `data_source_info` with type `dict[str, bool | str]` [bad-assignment]
-    --> services/dataset_service.py:2095:56
+    --> services/dataset_service.py:2098:56
 ERROR `dict[str, bool | dict[str, Any] | str | None]` is not assignable to variable `data_source_info` with type `dict[str, bool | str]` [bad-assignment]
-    --> services/dataset_service.py:2607:44
+    --> services/dataset_service.py:2610:44
 ERROR `None` is not assignable to attribute `rules` with type `Never` [bad-assignment]
-    --> services/dataset_service.py:2780:51
+    --> services/dataset_service.py:2783:51
 ERROR Class member `DocumentIndexingTaskProxy.NORMAL_TASK_FUNC` overrides parent class `BatchDocumentIndexingProxy` in an inconsistent manner [bad-override]
   --> services/document_indexing_proxy/document_indexing_task_proxy.py:11:5
 ERROR Class member `DocumentIndexingTaskProxy.PRIORITY_TASK_FUNC` overrides parent class `BatchDocumentIndexingProxy` in an inconsistent manner [bad-override]
@@ -550,7 +550,7 @@
 ERROR Returned type `dict[Unknown, Unknown] | None` is not assignable to declared return type `dict[str, Any]` [bad-return]
    --> services/external_knowledge_service.py:232:16
 ERROR `handled_tenant_count` was assigned in the current scope before the nonlocal declaration [unknown-name]
-  --> services/plugin/plugin_migration.py:72:34
+  --> services/plugin/plugin_migration.py:82:34
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
    --> services/summary_index_service.py:285:29
 ERROR Object of class `NoneType` has no attribute `summary_index_node_id` [missing-attribute]
@@ -5532,27 +5532,27 @@
 ERROR Argument `None` is not assignable to parameter `credentials` with type `dict[Unknown, Unknown]` in function `services.auth.api_key_auth_base.ApiKeyAuthBase.__init__` [bad-argument-type]
   --> tests/unit_tests/services/auth/test_api_key_auth_base.py:48:35
 ERROR Cannot index into `str` [bad-index]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:128:24
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:129:24
 ERROR Cannot index into `str` [bad-index]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:128:24
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:129:24
 ERROR Cannot index into `str` [bad-index]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:133:16
-ERROR Cannot index into `str` [bad-index]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:133:16
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:134:16
 ERROR Cannot index into `str` [bad-index]
    --> tests/unit_tests/services/auth/test_api_key_auth_service.py:134:16
+ERROR Cannot index into `str` [bad-index]
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:135:16
 ERROR `None` is not subscriptable [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:186:16
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:187:16
 ERROR Cannot set item in `dict[str, dict[str, dict[str, str] | str] | str]` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:271:31
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:272:31
 ERROR Cannot delete item in `str` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:287:13
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:288:13
 ERROR Cannot set item in `str` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:295:9
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:296:9
 ERROR Cannot set item in `str` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:383:9
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:384:9
 ERROR Cannot set item in `dict[str, dict[str, str] | str]` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:383:44
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:384:44
 ERROR No matching overload found for function `_pytest.raises.raises` called with arguments: (tuple[type[ValueError], type[KeyError], type[TypeError], type[AttributeError]]) [no-matching-overload]
    --> tests/unit_tests/services/auth/test_auth_integration.py:142:27
 ERROR No matching overload found for function `_pytest.raises.raises` called with arguments: (tuple[type[HTTPError], type[Exception]]) [no-matching-overload]
@@ -5629,25 +5629,25 @@
 ERROR `in` is not supported between `Literal['is not archived']` and `None` [not-iterable]
   --> tests/unit_tests/services/retention/workflow_run/test_delete_archived_workflow_run.py:91:20
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:612:67
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:613:67
 ERROR `in` is not supported between `Literal['Storage not configured']` and `None` [not-iterable]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:615:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:616:16
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:629:67
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:630:67
 ERROR `in` is not supported between `Literal['Archive bundle not found']` and `None` [not-iterable]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:632:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:633:16
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:652:63
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:653:63
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:708:71
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:709:71
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:734:67
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:735:67
 ERROR `in` is not supported between `Literal['File is not a zip file']` and `None` [not-iterable]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:738:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:739:16
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:758:71
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:759:71
 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:905:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:906:16
 ERROR Argument `None` is not assignable to parameter `name` with type `str` in function `_make_extension` [bad-argument-type]
    --> tests/unit_tests/services/test_api_based_extension_service.py:230:46
 ERROR Argument `None` is not assignable to parameter `api_endpoint` with type `str` in function `_make_extension` [bad-argument-type]

@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-03-19 18:15:34.720348413 +0000
+++ /tmp/pyrefly_pr.txt	2026-03-19 18:15:25.949381304 +0000
@@ -516,7 +516,7 @@
 ERROR No matching overload found for function `redis.client.Redis.__init__` called with arguments: (host=int | str | Unknown, port=int | str | Unknown, password=int | str | Unknown | None, db=int, ssl=bool, ssl_ca_certs=str | None, ssl_cert_reqs=Any | None, ssl_certfile=Any | None, ssl_keyfile=Any | None, socket_timeout=Literal[5], socket_connect_timeout=Literal[5], health_check_interval=Literal[30]) [no-matching-overload]
   --> schedule/queue_monitor_task.py:14:21
 ERROR Object of class `Tenant` has no attribute `role` [missing-attribute]
-    --> services/account_service.py:1121:13
+    --> services/account_service.py:1123:13
 ERROR Runtime checkable protocol `Generator` has an unsafe overlap with type `Iterable[bytes]` [unsafe-overlap]
    --> services/audio_service.py:145:41
 ERROR No matching overload found for function `flask.helpers.stream_with_context` called with arguments: (Generator[bytes]) [no-matching-overload]
@@ -528,11 +528,11 @@
 ERROR Argument `str | None` is not assignable to parameter `value` with type `SQLCoreOperations[str] | str` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
    --> services/conversation_service.py:131:33
 ERROR `dict[str, bool | dict[str, Any] | str | None]` is not assignable to variable `data_source_info` with type `dict[str, bool | str]` [bad-assignment]
-    --> services/dataset_service.py:2095:56
+    --> services/dataset_service.py:2098:56
 ERROR `dict[str, bool | dict[str, Any] | str | None]` is not assignable to variable `data_source_info` with type `dict[str, bool | str]` [bad-assignment]
-    --> services/dataset_service.py:2607:44
+    --> services/dataset_service.py:2610:44
 ERROR `None` is not assignable to attribute `rules` with type `Never` [bad-assignment]
-    --> services/dataset_service.py:2780:51
+    --> services/dataset_service.py:2783:51
 ERROR Class member `DocumentIndexingTaskProxy.NORMAL_TASK_FUNC` overrides parent class `BatchDocumentIndexingProxy` in an inconsistent manner [bad-override]
   --> services/document_indexing_proxy/document_indexing_task_proxy.py:11:5
 ERROR Class member `DocumentIndexingTaskProxy.PRIORITY_TASK_FUNC` overrides parent class `BatchDocumentIndexingProxy` in an inconsistent manner [bad-override]
@@ -550,7 +550,7 @@
 ERROR Returned type `dict[Unknown, Unknown] | None` is not assignable to declared return type `dict[str, Any]` [bad-return]
    --> services/external_knowledge_service.py:232:16
 ERROR `handled_tenant_count` was assigned in the current scope before the nonlocal declaration [unknown-name]
-  --> services/plugin/plugin_migration.py:72:34
+  --> services/plugin/plugin_migration.py:82:34
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
    --> services/summary_index_service.py:285:29
 ERROR Object of class `NoneType` has no attribute `summary_index_node_id` [missing-attribute]
@@ -5532,27 +5532,27 @@
 ERROR Argument `None` is not assignable to parameter `credentials` with type `dict[Unknown, Unknown]` in function `services.auth.api_key_auth_base.ApiKeyAuthBase.__init__` [bad-argument-type]
   --> tests/unit_tests/services/auth/test_api_key_auth_base.py:48:35
 ERROR Cannot index into `str` [bad-index]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:128:24
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:129:24
 ERROR Cannot index into `str` [bad-index]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:128:24
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:129:24
 ERROR Cannot index into `str` [bad-index]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:133:16
-ERROR Cannot index into `str` [bad-index]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:133:16
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:134:16
 ERROR Cannot index into `str` [bad-index]
    --> tests/unit_tests/services/auth/test_api_key_auth_service.py:134:16
+ERROR Cannot index into `str` [bad-index]
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:135:16
 ERROR `None` is not subscriptable [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:186:16
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:187:16
 ERROR Cannot set item in `dict[str, dict[str, dict[str, str] | str] | str]` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:271:31
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:272:31
 ERROR Cannot delete item in `str` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:287:13
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:288:13
 ERROR Cannot set item in `str` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:295:9
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:296:9
 ERROR Cannot set item in `str` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:383:9
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:384:9
 ERROR Cannot set item in `dict[str, dict[str, str] | str]` [unsupported-operation]
-   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:383:44
+   --> tests/unit_tests/services/auth/test_api_key_auth_service.py:384:44
 ERROR No matching overload found for function `_pytest.raises.raises` called with arguments: (tuple[type[ValueError], type[KeyError], type[TypeError], type[AttributeError]]) [no-matching-overload]
    --> tests/unit_tests/services/auth/test_auth_integration.py:142:27
 ERROR No matching overload found for function `_pytest.raises.raises` called with arguments: (tuple[type[HTTPError], type[Exception]]) [no-matching-overload]
@@ -5629,25 +5629,25 @@
 ERROR `in` is not supported between `Literal['is not archived']` and `None` [not-iterable]
   --> tests/unit_tests/services/retention/workflow_run/test_delete_archived_workflow_run.py:91:20
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:612:67
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:613:67
 ERROR `in` is not supported between `Literal['Storage not configured']` and `None` [not-iterable]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:615:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:616:16
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:629:67
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:630:67
 ERROR `in` is not supported between `Literal['Archive bundle not found']` and `None` [not-iterable]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:632:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:633:16
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:652:63
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:653:63
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:708:71
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:709:71
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:734:67
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:735:67
 ERROR `in` is not supported between `Literal['File is not a zip file']` and `None` [not-iterable]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:738:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:739:16
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:758:71
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:759:71
 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:905:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:906:16
 ERROR Argument `None` is not assignable to parameter `name` with type `str` in function `_make_extension` [bad-argument-type]
    --> tests/unit_tests/services/test_api_based_extension_service.py:230:46
 ERROR Argument `None` is not assignable to parameter `api_endpoint` with type `str` in function `_make_extension` [bad-argument-type]

@fury0928

Copy link
Copy Markdown
Contributor Author

@asukaminato0721 I am having trouble with one ci failing... it keeps failing... would you help me?
Thank you

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Mar 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-03-27 22:35:19.055398361 +0000
+++ /tmp/pyrefly_pr.txt	2026-03-27 22:35:08.933365223 +0000
@@ -381,7 +381,7 @@
 ERROR No matching overload found for function `redis.client.Redis.__init__` called with arguments: (host=int | str | Unknown, port=int | str | Unknown, password=int | str | Unknown | None, db=int, ssl=bool, ssl_ca_certs=str | None, ssl_cert_reqs=Any | None, ssl_certfile=Any | None, ssl_keyfile=Any | None, socket_timeout=Literal[5], socket_connect_timeout=Literal[5], health_check_interval=Literal[30]) [no-matching-overload]
   --> schedule/queue_monitor_task.py:14:21
 ERROR Object of class `Tenant` has no attribute `role` [missing-attribute]
-    --> services/account_service.py:1121:13
+    --> services/account_service.py:1131:13
 ERROR Runtime checkable protocol `Generator` has an unsafe overlap with type `Iterable[bytes]` [unsafe-overlap]
    --> services/audio_service.py:143:41
 ERROR No matching overload found for function `flask.helpers.stream_with_context` called with arguments: (Generator[bytes]) [no-matching-overload]
@@ -415,7 +415,7 @@
 ERROR Returned type `dict[Unknown, Unknown] | None` is not assignable to declared return type `dict[str, Any]` [bad-return]
    --> services/external_knowledge_service.py:232:16
 ERROR `handled_tenant_count` was assigned in the current scope before the nonlocal declaration [unknown-name]
-  --> services/plugin/plugin_migration.py:72:34
+  --> services/plugin/plugin_migration.py:82:34
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
    --> services/summary_index_service.py:287:29
 ERROR Object of class `NoneType` has no attribute `summary_index_node_id` [missing-attribute]
@@ -6635,26 +6635,28 @@
   --> tests/unit_tests/services/plugin/test_oauth_service.py:68:34
 ERROR Object of class `FunctionType` has no attribute `assert_called_once_with` [missing-attribute]
   --> tests/unit_tests/services/plugin/test_oauth_service.py:95:9
+ERROR Argument `dict[str, int]` is not assignable to parameter `manifest` with type `ArchiveManifest` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._get_schema_version` [bad-argument-type]
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:341:41
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:612:67
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:613:67
 ERROR `in` is not supported between `Literal['Storage not configured']` and `None` [not-iterable]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:615:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:616:16
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:629:67
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:630:67
 ERROR `in` is not supported between `Literal['Archive bundle not found']` and `None` [not-iterable]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:632:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:633:16
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:652:63
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:653:63
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:708:71
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:709:71
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:734:67
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:735:67
 ERROR `in` is not supported between `Literal['File is not a zip file']` and `None` [not-iterable]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:738:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:739:16
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:758:71
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:759:71
 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:905:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:906:16
 ERROR Object of class `FunctionType` has no attribute `reset_mock` [missing-attribute]
    --> tests/unit_tests/services/test_app_dsl_service.py:214:5
 ERROR Object of class `FunctionType` has no attribute `assert_called_once` [missing-attribute]

@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-03-27 22:37:01.973064927 +0000
+++ /tmp/pyrefly_pr.txt	2026-03-27 22:36:51.310993351 +0000
@@ -381,7 +381,7 @@
 ERROR No matching overload found for function `redis.client.Redis.__init__` called with arguments: (host=int | str | Unknown, port=int | str | Unknown, password=int | str | Unknown | None, db=int, ssl=bool, ssl_ca_certs=str | None, ssl_cert_reqs=Any | None, ssl_certfile=Any | None, ssl_keyfile=Any | None, socket_timeout=Literal[5], socket_connect_timeout=Literal[5], health_check_interval=Literal[30]) [no-matching-overload]
   --> schedule/queue_monitor_task.py:14:21
 ERROR Object of class `Tenant` has no attribute `role` [missing-attribute]
-    --> services/account_service.py:1121:13
+    --> services/account_service.py:1131:13
 ERROR Runtime checkable protocol `Generator` has an unsafe overlap with type `Iterable[bytes]` [unsafe-overlap]
    --> services/audio_service.py:143:41
 ERROR No matching overload found for function `flask.helpers.stream_with_context` called with arguments: (Generator[bytes]) [no-matching-overload]
@@ -415,7 +415,7 @@
 ERROR Returned type `dict[Unknown, Unknown] | None` is not assignable to declared return type `dict[str, Any]` [bad-return]
    --> services/external_knowledge_service.py:232:16
 ERROR `handled_tenant_count` was assigned in the current scope before the nonlocal declaration [unknown-name]
-  --> services/plugin/plugin_migration.py:72:34
+  --> services/plugin/plugin_migration.py:82:34
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
    --> services/summary_index_service.py:287:29
 ERROR Object of class `NoneType` has no attribute `summary_index_node_id` [missing-attribute]
@@ -6635,26 +6635,28 @@
   --> tests/unit_tests/services/plugin/test_oauth_service.py:68:34
 ERROR Object of class `FunctionType` has no attribute `assert_called_once_with` [missing-attribute]
   --> tests/unit_tests/services/plugin/test_oauth_service.py:95:9
+ERROR Argument `dict[str, int]` is not assignable to parameter `manifest` with type `ArchiveManifest` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._get_schema_version` [bad-argument-type]
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:341:41
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:612:67
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:613:67
 ERROR `in` is not supported between `Literal['Storage not configured']` and `None` [not-iterable]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:615:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:616:16
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:629:67
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:630:67
 ERROR `in` is not supported between `Literal['Archive bundle not found']` and `None` [not-iterable]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:632:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:633:16
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:652:63
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:653:63
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:708:71
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:709:71
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:734:67
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:735:67
 ERROR `in` is not supported between `Literal['File is not a zip file']` and `None` [not-iterable]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:738:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:739:16
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:758:71
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:759:71
 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:905:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:906:16
 ERROR Object of class `FunctionType` has no attribute `reset_mock` [missing-attribute]
    --> tests/unit_tests/services/test_app_dsl_service.py:214:5
 ERROR Object of class `FunctionType` has no attribute `assert_called_once` [missing-attribute]

@asukaminato0721

Copy link
Copy Markdown
Contributor

@asukaminato0721 I am having trouble with one ci failing... it keeps failing... would you help me? Thank you

It happens on some users, and it doesn't affect merge so... well, nvm.

@fury0928

Copy link
Copy Markdown
Contributor Author

@asukaminato0721 I am having trouble with one ci failing... it keeps failing... would you help me? Thank you

It happens on some users, and it doesn't affect merge so... well, nvm.

@asukaminato0721 would you merge this so that I can put following PRs?

@fury0928

Copy link
Copy Markdown
Contributor Author

Hi @asukaminato0721 would you merge this?
Thank you

@asukaminato0721

Copy link
Copy Markdown
Contributor

TypeAdapter(dict[str, str]) for icon parsing adds no meaningful
validation over json.loads. Revert to json.loads per reviewer
feedback.
auto-merge was automatically disabled March 30, 2026 06:36

Head branch was pushed to by a user without write access

@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-03-30 06:37:16.495923739 +0000
+++ /tmp/pyrefly_pr.txt	2026-03-30 06:37:06.562790455 +0000
@@ -381,7 +381,7 @@
 ERROR No matching overload found for function `redis.client.Redis.__init__` called with arguments: (host=int | str | Unknown, port=int | str | Unknown, password=int | str | Unknown | None, db=int, ssl=bool, ssl_ca_certs=str | None, ssl_cert_reqs=Any | None, ssl_certfile=Any | None, ssl_keyfile=Any | None, socket_timeout=Literal[5], socket_connect_timeout=Literal[5], health_check_interval=Literal[30]) [no-matching-overload]
   --> schedule/queue_monitor_task.py:14:21
 ERROR Object of class `Tenant` has no attribute `role` [missing-attribute]
-    --> services/account_service.py:1121:13
+    --> services/account_service.py:1131:13
 ERROR Runtime checkable protocol `Generator` has an unsafe overlap with type `Iterable[bytes]` [unsafe-overlap]
    --> services/audio_service.py:143:41
 ERROR No matching overload found for function `flask.helpers.stream_with_context` called with arguments: (Generator[bytes]) [no-matching-overload]
@@ -415,7 +415,7 @@
 ERROR Returned type `dict[Unknown, Unknown] | None` is not assignable to declared return type `dict[str, Any]` [bad-return]
    --> services/external_knowledge_service.py:232:16
 ERROR `handled_tenant_count` was assigned in the current scope before the nonlocal declaration [unknown-name]
-  --> services/plugin/plugin_migration.py:72:34
+  --> services/plugin/plugin_migration.py:82:34
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
    --> services/summary_index_service.py:287:29
 ERROR Object of class `NoneType` has no attribute `summary_index_node_id` [missing-attribute]
@@ -6647,26 +6647,28 @@
   --> tests/unit_tests/services/plugin/test_oauth_service.py:68:34
 ERROR Object of class `FunctionType` has no attribute `assert_called_once_with` [missing-attribute]
   --> tests/unit_tests/services/plugin/test_oauth_service.py:95:9
+ERROR Argument `dict[str, int]` is not assignable to parameter `manifest` with type `ArchiveManifest` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._get_schema_version` [bad-argument-type]
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:341:41
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:612:67
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:613:67
 ERROR `in` is not supported between `Literal['Storage not configured']` and `None` [not-iterable]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:615:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:616:16
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:629:67
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:630:67
 ERROR `in` is not supported between `Literal['Archive bundle not found']` and `None` [not-iterable]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:632:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:633:16
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:652:63
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:653:63
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:708:71
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:709:71
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:734:67
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:735:67
 ERROR `in` is not supported between `Literal['File is not a zip file']` and `None` [not-iterable]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:738:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:739:16
 ERROR Argument `() -> Mock` is not assignable to parameter `session_maker` with type `sessionmaker[Unknown]` in function `services.retention.workflow_run.restore_archived_workflow_run.WorkflowRunRestore._restore_from_run` [bad-argument-type]
-   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:758:71
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:759:71
 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:905:16
+   --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:906:16
 ERROR Object of class `FunctionType` has no attribute `reset_mock` [missing-attribute]
    --> tests/unit_tests/services/test_app_dsl_service.py:214:5
 ERROR Object of class `FunctionType` has no attribute `assert_called_once` [missing-attribute]

@fury0928

Copy link
Copy Markdown
Contributor Author

Hi @asukaminato0721 would you merge this? Thank you

https://github.com/langgenius/dify/pull/33704/changes#r3004203002

Looks good now?

@fury0928

Copy link
Copy Markdown
Contributor Author

Thank you @asukaminato0721
Will this be merged soon? because there are 2-3 more PRs on the same issue

@asukaminato0721
asukaminato0721 self-requested a review March 30, 2026 08:21
@asukaminato0721
asukaminato0721 added this pull request to the merge queue Mar 30, 2026
Merged via the queue into langgenius:main with commit 944db46 Mar 30, 2026
26 of 27 checks passed
Ssazurov pushed a commit to Ssazurov/dify that referenced this pull request Aug 8, 2026
…s layer (langgenius#33704)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Asuka Minato <i@asukaminato.eu.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer refactor size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants