Repository navigation
refactor: pass db.session explicitly in billing and credential_permission services (#37403) - #37716
Closed
EvanYao826 wants to merge 2 commits into
Closed
EvanYao826 wants to merge 2 commits into
EvanYao826 wants to merge 2 commits into
Conversation
Migrate db.session to explicit session parameter in: - billing_service.py (is_tenant_owner_or_admin) - credential_permission_service.py (get_partial_member_list) - agent_app_sandbox_service.py (no db.session usage found, skipped) Follows pattern from langgenius#37402.
EvanYao826
requested review from
QuantumGhost,
hj24,
laipz8200 and
zyssyz123
as code owners
June 22, 2026 02:18
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-06-30 02:20:49.935207310 +0000
+++ /tmp/pyrefly_pr.txt 2026-06-30 02:20:36.335177373 +0000
@@ -1,3 +1,9 @@
+ERROR Argument `scoped_session[flask_sqlalchemy.session.Session]` is not assignable to parameter `session` with type `sqlalchemy.orm.session.Session` in function `services.billing_service.BillingService.is_tenant_owner_or_admin` [bad-argument-type]
+ --> controllers/console/billing/billing.py:54:49
+ERROR Argument `scoped_session[flask_sqlalchemy.session.Session]` is not assignable to parameter `session` with type `sqlalchemy.orm.session.Session` in function `services.billing_service.BillingService.is_tenant_owner_or_admin` [bad-argument-type]
+ --> controllers/console/billing/billing.py:68:49
+ERROR Argument `scoped_session[flask_sqlalchemy.session.Session]` is not assignable to parameter `session` with type `sqlalchemy.orm.session.Session` in function `services.billing_service.BillingService.is_tenant_owner_or_admin` [bad-argument-type]
+ --> controllers/console/workspace/model_providers.py:356:49
ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `dify_vdb_alibabacloud_mysql.alibabacloud_mysql_vector.AlibabaCloudMySQLVectorFactory.init_vector` [bad-argument-type]
--> providers/vdb/vdb-alibabacloud-mysql/tests/unit_tests/test_alibabacloud_mysql_factory.py:42:38
ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `dify_vdb_alibabacloud_mysql.alibabacloud_mysql_vector.AlibabaCloudMySQLVectorFactory.init_vector` [bad-argument-type]
@@ -460,6 +466,8 @@
--> providers/vdb/vdb-weaviate/tests/unit_tests/test_weaviate_vector.py:891:42
ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `dify_vdb_weaviate.weaviate_vector.WeaviateVectorFactory.init_vector` [bad-argument-type]
--> providers/vdb/vdb-weaviate/tests/unit_tests/test_weaviate_vector.py:920:42
+ERROR Argument `scoped_session[flask_sqlalchemy.session.Session]` is not assignable to parameter `session` with type `sqlalchemy.orm.session.Session` in function `services.credential_permission_service.CredentialPermissionService.get_partial_member_list` [bad-argument-type]
+ --> services/tools/builtin_tools_manage_service.py:430:29
ERROR Object of class `FromClause` has no attribute `metadata` [missing-attribute]
--> tests/helpers/legacy_model_type_migration.py:64:16
ERROR Object of class `FromClause` has no attribute `metadata` [missing-attribute]
@@ -6949,14 +6957,56 @@
--> tests/unit_tests/services/test_async_workflow_service.py:289:26
ERROR Argument `SimpleNamespace` is not assignable to parameter `user` with type `Account | EndUser` in function `services.async_workflow_service.AsyncWorkflowService.reinvoke_trigger` [bad-argument-type]
--> tests/unit_tests/services/test_async_workflow_service.py:322:22
+ERROR Parse error: Expected a statement [parse-error]
+ --> tests/unit_tests/services/test_billing_service.py:1120:1
+ERROR Parse error: Expected a statement [parse-error]
+ --> tests/unit_tests/services/test_billing_service.py:1120:3
+ERROR Parse error: Expected a statement [parse-error]
+ --> tests/unit_tests/services/test_billing_service.py:1120:5
+ERROR Parse error: Expected a statement [parse-error]
+ --> tests/unit_tests/services/test_billing_service.py:1120:7
+ERROR Parse error: Expected a statement [parse-error]
+ --> tests/unit_tests/services/test_billing_service.py:1120:8
+ERROR Parse error: Unexpected indentation [parse-error]
+ --> tests/unit_tests/services/test_billing_service.py:1121:1
+ERROR Could not find name `mock_db_session` [unknown-name]
+ --> tests/unit_tests/services/test_billing_service.py:1121:9
+ERROR Parse error: Expected a statement [parse-error]
+ --> tests/unit_tests/services/test_billing_service.py:1122:1
+ERROR Parse error: Expected a statement [parse-error]
+ --> tests/unit_tests/services/test_billing_service.py:1122:3
+ERROR Parse error: Expected a statement [parse-error]
+ --> tests/unit_tests/services/test_billing_service.py:1122:5
+ERROR Parse error: Expected a statement [parse-error]
+ --> tests/unit_tests/services/test_billing_service.py:1122:7
+ERROR Could not find name `upstream` [unknown-name]
+ --> tests/unit_tests/services/test_billing_service.py:1122:9
+ERROR Could not find name `main` [unknown-name]
+ --> tests/unit_tests/services/test_billing_service.py:1122:18
+ERROR Parse error: Unexpected indentation [parse-error]
+ --> tests/unit_tests/services/test_billing_service.py:1124:1
+ERROR Parse error: Expected a statement [parse-error]
+ --> tests/unit_tests/services/test_billing_service.py:1138:1
+ERROR Parse error: Expected a statement [parse-error]
+ --> tests/unit_tests/services/test_billing_service.py:1138:3
+ERROR Parse error: Expected a statement [parse-error]
+ --> tests/unit_tests/services/test_billing_service.py:1138:5
+ERROR Parse error: Expected a statement [parse-error]
+ --> tests/unit_tests/services/test_billing_service.py:1138:7
+ERROR Could not find name `HEAD` [unknown-name]
+ --> tests/unit_tests/services/test_billing_service.py:1138:9
+ERROR Parse error: Unexpected indentation [parse-error]
+ --> tests/unit_tests/services/test_billing_service.py:1140:1
+ERROR Parse error: Expected a statement [parse-error]
+ --> tests/unit_tests/services/test_billing_service.py:1174:1
ERROR Argument `BillingInfo` is not assignable to parameter `result` with type `dict[Unknown, Unknown]` in function `TestBillingServiceSubscriptionInfoDataType._assert_billing_info_types` [bad-argument-type]
- --> tests/unit_tests/services/test_billing_service.py:1856:41
+ --> tests/unit_tests/services/test_billing_service.py:1859:41
ERROR Argument `BillingInfo` is not assignable to parameter `result` with type `dict[Unknown, Unknown]` in function `TestBillingServiceSubscriptionInfoDataType._assert_billing_info_types` [bad-argument-type]
- --> tests/unit_tests/services/test_billing_service.py:1865:41
+ --> tests/unit_tests/services/test_billing_service.py:1868:41
ERROR Argument `BillingInfo` is not assignable to parameter `result` with type `dict[Unknown, Unknown]` in function `TestBillingServiceSubscriptionInfoDataType._assert_billing_info_types` [bad-argument-type]
- --> tests/unit_tests/services/test_billing_service.py:1878:41
+ --> tests/unit_tests/services/test_billing_service.py:1881:41
ERROR Argument `BillingInfo` is not assignable to parameter `result` with type `dict[Unknown, Unknown]` in function `TestBillingServiceSubscriptionInfoDataType._assert_billing_info_types` [bad-argument-type]
- --> tests/unit_tests/services/test_billing_service.py:1889:41
+ --> tests/unit_tests/services/test_billing_service.py:1892:41
ERROR Argument `FakeRepo` is not assignable to parameter `workflow_run_repo` with type `APIWorkflowRunRepository | None` in function `services.retention.workflow_run.clear_free_plan_expired_workflow_run_logs.WorkflowRunCleanup.__init__` [bad-argument-type]
--> tests/unit_tests/services/test_clear_free_plan_expired_workflow_run_logs.py:126:49
ERROR Class member `FailingRepo.delete_runs_with_related_by_ids` overrides a member in a parent class but is missing an `@override` decorator [missing-override-decorator]
@@ -6970,9 +7020,9 @@
ERROR Class member `FixedDateTime.now` overrides a member in a parent class but is missing an `@override` decorator [missing-override-decorator]
--> tests/unit_tests/services/test_clear_free_plan_tenant_expired_logs.py:483:13
ERROR Argument `SimpleNamespace` is not assignable to parameter `user` with type `Account` in function `services.credential_permission_service.CredentialPermissionService.apply_visibility_filter` [bad-argument-type]
- --> tests/unit_tests/services/test_credential_permission_service.py:82:18
+ --> tests/unit_tests/services/test_credential_permission_service.py:80:18
ERROR Argument `SimpleNamespace` is not assignable to parameter `user` with type `Account` in function `services.credential_permission_service.CredentialPermissionService.apply_visibility_filter` [bad-argument-type]
- --> tests/unit_tests/services/test_credential_permission_service.py:99:18
+ --> tests/unit_tests/services/test_credential_permission_service.py:97:18
ERROR Object of class `FromClause` has no attribute `create` [missing-attribute]
--> tests/unit_tests/services/test_credit_pool_service.py:24:5
ERROR Object of class `FromClause` has no attribute `insert` [missing-attribute]
|
Contributor
Pyrefly Type Coverage
|
Contributor
|
fix ci |
This was referenced Jul 23, 2026
3 of 5 tasks
Member
|
Thank you for your contribution and the effort you’ve put into this PR. It currently has merge conflicts with |
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
Migrate
db.sessionusage to explicitsessionparameter in 2 service files, following the pattern established in #37402.Changes
api/services/billing_service.py:is_tenant_owner_or_admin(): Addedsession: Sessionas first parameterdb.session.scalar→session.scalarfrom extensions.ext_database import dbapi/services/credential_permission_service.py:get_partial_member_list(): Addedsession: Sessionas first parameterdb.session.scalars→session.scalarsfrom extensions.ext_database import dbCallers updated (3 files):
api/controllers/console/billing/billing.py— 2 call sitesapi/controllers/console/workspace/model_providers.py— 1 call siteapi/services/tools/builtin_tools_manage_service.py— 1 call siteTests updated (3 files):
api/tests/unit_tests/services/test_billing_service.pyapi/tests/unit_tests/services/test_credential_permission_service.pyapi/tests/test_containers_integration_tests/services/test_billing_service.pyPattern
All 101 tests pass. Closes #37403 (partial).