refactor(api): type Tenant custom config with TypedDict and tighten MCP headers type#34670
Merged
asukaminato0721 merged 1 commit intolanggenius:mainfrom Apr 7, 2026
Conversation
asukaminato0721
previously approved these changes
Apr 7, 2026
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-07 11:43:28.297344380 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-07 11:43:18.313505027 +0000
@@ -14,6 +14,8 @@
--> controllers/console/setup.py:65:2
ERROR Object of class `MissingRouter` has no attribute `get` [missing-attribute]
--> controllers/console/version.py:30:2
+ERROR Argument `dict[str, bool | str | None]` is not assignable to parameter `value` with type `TenantCustomConfigDict` in function `models.account.Tenant.custom_config_dict` [bad-argument-type]
+ --> controllers/console/workspace/workspace.py:250:37
ERROR Class member `EasyUIBasedGenerateTaskPipeline._application_generate_entity` overrides parent class `BasedGenerateTaskPipeline` in an inconsistent manner [bad-override]
--> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:75:5
ERROR `+=` is not supported between `list[PromptMessageContentUnionTypes]` and `str` [unsupported-operation]
@@ -765,6 +767,14 @@
--> tests/test_containers_integration_tests/services/test_account_service.py:1998:16
ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
--> tests/test_containers_integration_tests/services/test_account_service.py:2144:16
+ERROR Argument `dict[str, dict[str, bool] | str]` is not assignable to parameter `value` with type `TenantCustomConfigDict` in function `models.account.Tenant.custom_config_dict` [bad-argument-type]
+ --> tests/test_containers_integration_tests/services/test_account_service.py:2311:37
+ERROR TypedDict `TenantCustomConfigDict` does not have key `theme` [bad-typed-dict-key]
+ --> tests/test_containers_integration_tests/services/test_account_service.py:2319:33
+ERROR TypedDict `TenantCustomConfigDict` does not have key `language` [bad-typed-dict-key]
+ --> tests/test_containers_integration_tests/services/test_account_service.py:2320:33
+ERROR TypedDict `TenantCustomConfigDict` does not have key `feature_flags` [bad-typed-dict-key]
+ --> tests/test_containers_integration_tests/services/test_account_service.py:2321:33
ERROR Argument `Literal['pending']` is not assignable to parameter `value` with type `AccountStatus | SQLCoreOperations[AccountStatus]` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
--> tests/test_containers_integration_tests/services/test_account_service.py:2854:35
ERROR Argument `Literal['active']` is not assignable to parameter `value` with type `AccountStatus | SQLCoreOperations[AccountStatus]` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
@@ -6133,6 +6143,12 @@
--> tests/unit_tests/libs/test_token.py:29:37
ERROR Argument `MockRequest` is not assignable to parameter `request` with type `Request` in function `libs.token.extract_webapp_access_token` [bad-argument-type]
--> tests/unit_tests/libs/test_token.py:30:44
+ERROR TypedDict `TenantCustomConfigDict` does not have key `feature1` [bad-typed-dict-key]
+ --> tests/unit_tests/models/test_account_models.py:736:23
+ERROR TypedDict `TenantCustomConfigDict` does not have key `feature2` [bad-typed-dict-key]
+ --> tests/unit_tests/models/test_account_models.py:737:23
+ERROR Argument `dict[str, bool | str]` is not assignable to parameter `value` with type `TenantCustomConfigDict` in function `models.account.Tenant.custom_config_dict` [bad-argument-type]
+ --> tests/unit_tests/models/test_account_models.py:758:37
ERROR `None` is not subscriptable [unsupported-operation]
--> tests/unit_tests/models/test_app_models.py:1293:20
ERROR `None` is not subscriptable [unsupported-operation]
|
auto-merge was automatically disabled
April 7, 2026 11:51
Head branch was pushed to by a user without write access
e86c96c to
d13a157
Compare
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-07 11:52:08.850509901 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-07 11:51:59.804495742 +0000
@@ -14,6 +14,8 @@
--> controllers/console/setup.py:65:2
ERROR Object of class `MissingRouter` has no attribute `get` [missing-attribute]
--> controllers/console/version.py:30:2
+ERROR `bool | None` is not assignable to TypedDict key `remove_webapp_brand` with type `bool` [bad-typed-dict-key]
+ --> controllers/console/workspace/workspace.py:244:36
ERROR Class member `EasyUIBasedGenerateTaskPipeline._application_generate_entity` overrides parent class `BasedGenerateTaskPipeline` in an inconsistent manner [bad-override]
--> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:75:5
ERROR `+=` is not supported between `list[PromptMessageContentUnionTypes]` and `str` [unsupported-operation]
@@ -765,6 +767,14 @@
--> tests/test_containers_integration_tests/services/test_account_service.py:1998:16
ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
--> tests/test_containers_integration_tests/services/test_account_service.py:2144:16
+ERROR Argument `dict[str, dict[str, bool] | str]` is not assignable to parameter `value` with type `TenantCustomConfigDict` in function `models.account.Tenant.custom_config_dict` [bad-argument-type]
+ --> tests/test_containers_integration_tests/services/test_account_service.py:2311:37
+ERROR TypedDict `TenantCustomConfigDict` does not have key `theme` [bad-typed-dict-key]
+ --> tests/test_containers_integration_tests/services/test_account_service.py:2319:33
+ERROR TypedDict `TenantCustomConfigDict` does not have key `language` [bad-typed-dict-key]
+ --> tests/test_containers_integration_tests/services/test_account_service.py:2320:33
+ERROR TypedDict `TenantCustomConfigDict` does not have key `feature_flags` [bad-typed-dict-key]
+ --> tests/test_containers_integration_tests/services/test_account_service.py:2321:33
ERROR Argument `Literal['pending']` is not assignable to parameter `value` with type `AccountStatus | SQLCoreOperations[AccountStatus]` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
--> tests/test_containers_integration_tests/services/test_account_service.py:2854:35
ERROR Argument `Literal['active']` is not assignable to parameter `value` with type `AccountStatus | SQLCoreOperations[AccountStatus]` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
@@ -6133,6 +6143,12 @@
--> tests/unit_tests/libs/test_token.py:29:37
ERROR Argument `MockRequest` is not assignable to parameter `request` with type `Request` in function `libs.token.extract_webapp_access_token` [bad-argument-type]
--> tests/unit_tests/libs/test_token.py:30:44
+ERROR TypedDict `TenantCustomConfigDict` does not have key `feature1` [bad-typed-dict-key]
+ --> tests/unit_tests/models/test_account_models.py:736:23
+ERROR TypedDict `TenantCustomConfigDict` does not have key `feature2` [bad-typed-dict-key]
+ --> tests/unit_tests/models/test_account_models.py:737:23
+ERROR Argument `dict[str, bool | str]` is not assignable to parameter `value` with type `TenantCustomConfigDict` in function `models.account.Tenant.custom_config_dict` [bad-argument-type]
+ --> tests/unit_tests/models/test_account_models.py:758:37
ERROR `None` is not subscriptable [unsupported-operation]
--> tests/unit_tests/models/test_app_models.py:1293:20
ERROR `None` is not subscriptable [unsupported-operation]
|
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-07 11:52:13.638230134 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-07 11:52:04.956224355 +0000
@@ -14,6 +14,8 @@
--> controllers/console/setup.py:65:2
ERROR Object of class `MissingRouter` has no attribute `get` [missing-attribute]
--> controllers/console/version.py:30:2
+ERROR `bool | None` is not assignable to TypedDict key `remove_webapp_brand` with type `bool` [bad-typed-dict-key]
+ --> controllers/console/workspace/workspace.py:244:36
ERROR Class member `EasyUIBasedGenerateTaskPipeline._application_generate_entity` overrides parent class `BasedGenerateTaskPipeline` in an inconsistent manner [bad-override]
--> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:75:5
ERROR `+=` is not supported between `list[PromptMessageContentUnionTypes]` and `str` [unsupported-operation]
@@ -765,6 +767,14 @@
--> tests/test_containers_integration_tests/services/test_account_service.py:1998:16
ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
--> tests/test_containers_integration_tests/services/test_account_service.py:2144:16
+ERROR Argument `dict[str, dict[str, bool] | str]` is not assignable to parameter `value` with type `TenantCustomConfigDict` in function `models.account.Tenant.custom_config_dict` [bad-argument-type]
+ --> tests/test_containers_integration_tests/services/test_account_service.py:2311:37
+ERROR TypedDict `TenantCustomConfigDict` does not have key `theme` [bad-typed-dict-key]
+ --> tests/test_containers_integration_tests/services/test_account_service.py:2319:33
+ERROR TypedDict `TenantCustomConfigDict` does not have key `language` [bad-typed-dict-key]
+ --> tests/test_containers_integration_tests/services/test_account_service.py:2320:33
+ERROR TypedDict `TenantCustomConfigDict` does not have key `feature_flags` [bad-typed-dict-key]
+ --> tests/test_containers_integration_tests/services/test_account_service.py:2321:33
ERROR Argument `Literal['pending']` is not assignable to parameter `value` with type `AccountStatus | SQLCoreOperations[AccountStatus]` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
--> tests/test_containers_integration_tests/services/test_account_service.py:2854:35
ERROR Argument `Literal['active']` is not assignable to parameter `value` with type `AccountStatus | SQLCoreOperations[AccountStatus]` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
@@ -6133,6 +6143,12 @@
--> tests/unit_tests/libs/test_token.py:29:37
ERROR Argument `MockRequest` is not assignable to parameter `request` with type `Request` in function `libs.token.extract_webapp_access_token` [bad-argument-type]
--> tests/unit_tests/libs/test_token.py:30:44
+ERROR TypedDict `TenantCustomConfigDict` does not have key `feature1` [bad-typed-dict-key]
+ --> tests/unit_tests/models/test_account_models.py:736:23
+ERROR TypedDict `TenantCustomConfigDict` does not have key `feature2` [bad-typed-dict-key]
+ --> tests/unit_tests/models/test_account_models.py:737:23
+ERROR Argument `dict[str, bool | str]` is not assignable to parameter `value` with type `TenantCustomConfigDict` in function `models.account.Tenant.custom_config_dict` [bad-argument-type]
+ --> tests/unit_tests/models/test_account_models.py:758:37
ERROR `None` is not subscriptable [unsupported-operation]
--> tests/unit_tests/models/test_app_models.py:1293:20
ERROR `None` is not subscriptable [unsupported-operation]
|
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-07 11:57:41.925715044 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-07 11:57:32.267632639 +0000
@@ -14,6 +14,8 @@
--> controllers/console/setup.py:65:2
ERROR Object of class `MissingRouter` has no attribute `get` [missing-attribute]
--> controllers/console/version.py:30:2
+ERROR `bool | None` is not assignable to TypedDict key `remove_webapp_brand` with type `bool` [bad-typed-dict-key]
+ --> controllers/console/workspace/workspace.py:244:36
ERROR Class member `EasyUIBasedGenerateTaskPipeline._application_generate_entity` overrides parent class `BasedGenerateTaskPipeline` in an inconsistent manner [bad-override]
--> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:75:5
ERROR `+=` is not supported between `list[PromptMessageContentUnionTypes]` and `str` [unsupported-operation]
@@ -765,6 +767,14 @@
--> tests/test_containers_integration_tests/services/test_account_service.py:1998:16
ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
--> tests/test_containers_integration_tests/services/test_account_service.py:2144:16
+ERROR Argument `dict[str, dict[str, bool] | str]` is not assignable to parameter `value` with type `TenantCustomConfigDict` in function `models.account.Tenant.custom_config_dict` [bad-argument-type]
+ --> tests/test_containers_integration_tests/services/test_account_service.py:2311:37
+ERROR TypedDict `TenantCustomConfigDict` does not have key `theme` [bad-typed-dict-key]
+ --> tests/test_containers_integration_tests/services/test_account_service.py:2319:33
+ERROR TypedDict `TenantCustomConfigDict` does not have key `language` [bad-typed-dict-key]
+ --> tests/test_containers_integration_tests/services/test_account_service.py:2320:33
+ERROR TypedDict `TenantCustomConfigDict` does not have key `feature_flags` [bad-typed-dict-key]
+ --> tests/test_containers_integration_tests/services/test_account_service.py:2321:33
ERROR Argument `Literal['pending']` is not assignable to parameter `value` with type `AccountStatus | SQLCoreOperations[AccountStatus]` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
--> tests/test_containers_integration_tests/services/test_account_service.py:2854:35
ERROR Argument `Literal['active']` is not assignable to parameter `value` with type `AccountStatus | SQLCoreOperations[AccountStatus]` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
@@ -6133,6 +6143,12 @@
--> tests/unit_tests/libs/test_token.py:29:37
ERROR Argument `MockRequest` is not assignable to parameter `request` with type `Request` in function `libs.token.extract_webapp_access_token` [bad-argument-type]
--> tests/unit_tests/libs/test_token.py:30:44
+ERROR TypedDict `TenantCustomConfigDict` does not have key `feature1` [bad-typed-dict-key]
+ --> tests/unit_tests/models/test_account_models.py:736:23
+ERROR TypedDict `TenantCustomConfigDict` does not have key `feature2` [bad-typed-dict-key]
+ --> tests/unit_tests/models/test_account_models.py:737:23
+ERROR Argument `dict[str, bool | str]` is not assignable to parameter `value` with type `TenantCustomConfigDict` in function `models.account.Tenant.custom_config_dict` [bad-argument-type]
+ --> tests/unit_tests/models/test_account_models.py:758:37
ERROR `None` is not subscriptable [unsupported-operation]
--> tests/unit_tests/models/test_app_models.py:1293:20
ERROR `None` is not subscriptable [unsupported-operation]
|
auto-merge was automatically disabled
April 7, 2026 12:10
Head branch was pushed to by a user without write access
a5f4046 to
348f58b
Compare
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-07 12:11:07.054074220 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-07 12:10:58.554135861 +0000
@@ -765,6 +765,14 @@
--> tests/test_containers_integration_tests/services/test_account_service.py:1998:16
ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
--> tests/test_containers_integration_tests/services/test_account_service.py:2144:16
+ERROR Argument `dict[str, dict[str, bool] | str]` is not assignable to parameter `value` with type `TenantCustomConfigDict` in function `models.account.Tenant.custom_config_dict` [bad-argument-type]
+ --> tests/test_containers_integration_tests/services/test_account_service.py:2311:37
+ERROR TypedDict `TenantCustomConfigDict` does not have key `theme` [bad-typed-dict-key]
+ --> tests/test_containers_integration_tests/services/test_account_service.py:2319:33
+ERROR TypedDict `TenantCustomConfigDict` does not have key `language` [bad-typed-dict-key]
+ --> tests/test_containers_integration_tests/services/test_account_service.py:2320:33
+ERROR TypedDict `TenantCustomConfigDict` does not have key `feature_flags` [bad-typed-dict-key]
+ --> tests/test_containers_integration_tests/services/test_account_service.py:2321:33
ERROR Argument `Literal['pending']` is not assignable to parameter `value` with type `AccountStatus | SQLCoreOperations[AccountStatus]` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
--> tests/test_containers_integration_tests/services/test_account_service.py:2854:35
ERROR Argument `Literal['active']` is not assignable to parameter `value` with type `AccountStatus | SQLCoreOperations[AccountStatus]` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
@@ -6133,6 +6141,12 @@
--> tests/unit_tests/libs/test_token.py:29:37
ERROR Argument `MockRequest` is not assignable to parameter `request` with type `Request` in function `libs.token.extract_webapp_access_token` [bad-argument-type]
--> tests/unit_tests/libs/test_token.py:30:44
+ERROR TypedDict `TenantCustomConfigDict` does not have key `feature1` [bad-typed-dict-key]
+ --> tests/unit_tests/models/test_account_models.py:736:23
+ERROR TypedDict `TenantCustomConfigDict` does not have key `feature2` [bad-typed-dict-key]
+ --> tests/unit_tests/models/test_account_models.py:737:23
+ERROR Argument `dict[str, bool | str]` is not assignable to parameter `value` with type `TenantCustomConfigDict` in function `models.account.Tenant.custom_config_dict` [bad-argument-type]
+ --> tests/unit_tests/models/test_account_models.py:758:37
ERROR `None` is not subscriptable [unsupported-operation]
--> tests/unit_tests/models/test_app_models.py:1293:20
ERROR `None` is not subscriptable [unsupported-operation]
|
asukaminato0721
approved these changes
Apr 7, 2026
HanqingZ
pushed a commit
to HanqingZ/dify
that referenced
this pull request
Apr 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TenantCustomConfigDictTypedDict (total=False) with keysremove_webapp_brand(bool) andreplace_webapp_logo(str | None)Tenant.custom_config_dictproperty and setter withTenantCustomConfigDict(wasdict[str, Any])MCPToolProvider.headersreturn type fromdict[str, Any]todict[str, str](HTTP headers are string-valued)Anyimport fromaccount.pyWhy this change
Tenant.custom_config_dictstores workspace branding config with two well-known keys accessed by name across 4 call sites (remove_webapp_brand,replace_webapp_logo). The TypedDict makes this contract explicit.MCPToolProvider.headersreturns HTTP headers which are alwaysstr: str—dict[str, Any]was overly broad.Changes
models/account.py: DefineTenantCustomConfigDict, update property/setter typesmodels/tools.py: Tightenheadersreturn type todict[str, str]Test plan
ruff checkpassesPart of #32863 (
models/account.py,models/tools.py)