Skip to content

fix: fix orm_exc.DetachedInstanceError#34904

Merged
asukaminato0721 merged 2 commits intolanggenius:mainfrom
fatelei:issue-34902
Apr 10, 2026
Merged

fix: fix orm_exc.DetachedInstanceError#34904
asukaminato0721 merged 2 commits intolanggenius:mainfrom
fatelei:issue-34902

Conversation

@fatelei
Copy link
Copy Markdown
Contributor

@fatelei fatelei commented Apr 10, 2026

Important

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

Summary

fix #34902

Screenshots

Before After
... ...

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint and make type-check (backend) and cd web && pnpm exec vp staged (frontend) to appease the lint gods

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Apr 10, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-04-10 06:30:47.145261242 +0000
+++ /tmp/pyrefly_pr.txt	2026-04-10 06:30:37.112245569 +0000
@@ -1,7 +1,7 @@
 ERROR Object of class `App` has no attribute `access_mode` [missing-attribute]
    --> controllers/console/app/app.py:561:13
 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
+  --> controllers/console/auth/email_register.py:76:108
 ERROR Object of class `MissingRouter` has no attribute `get` [missing-attribute]
   --> controllers/console/init_validate.py:31:2
 ERROR Object of class `MissingRouter` has no attribute `post` [missing-attribute]
@@ -316,7 +316,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:1153:13
+    --> services/account_service.py:1154:13
 ERROR No matching overload found for function `flask.helpers.stream_with_context` called with arguments: (Generator[bytes]) [no-matching-overload]
    --> services/audio_service.py:144:56
 ERROR No matching overload found for function `flask.helpers.stream_with_context` called with arguments: (Generator[bytes]) [no-matching-overload]
@@ -577,10 +577,16 @@
    --> tests/test_containers_integration_tests/controllers/console/app/test_app_apis.py:600:51
 ERROR Argument `Literal['normal']` is not assignable to parameter `status` with type `SQLCoreOperations[TenantStatus] | TenantStatus` in function `models.account.Tenant.__init__` [bad-argument-type]
   --> tests/test_containers_integration_tests/controllers/console/app/test_chat_conversation_status_count_api.py:33:48
+ERROR Unexpected keyword argument `session` in function `services.account_service.AccountService.get_account_by_email_with_case_fallback` [unexpected-keyword]
+   --> tests/test_containers_integration_tests/controllers/console/auth/test_email_register.py:161:86
+ERROR Unexpected keyword argument `session` in function `services.account_service.AccountService.get_account_by_email_with_case_fallback` [unexpected-keyword]
+   --> tests/test_containers_integration_tests/controllers/console/auth/test_forgot_password.py:164:87
 ERROR Object of class `RequestError` has no attribute `response` [missing-attribute]
    --> tests/test_containers_integration_tests/controllers/console/auth/test_oauth.py:196:9
 ERROR Object of class `RequestError` has no attribute `response` [missing-attribute]
    --> tests/test_containers_integration_tests/controllers/console/auth/test_oauth.py:197:9
+ERROR Unexpected keyword argument `session` in function `services.account_service.AccountService.get_account_by_email_with_case_fallback` [unexpected-keyword]
+   --> tests/test_containers_integration_tests/controllers/console/auth/test_oauth.py:440:90
 ERROR Argument `Literal['normal']` is not assignable to parameter `status` with type `SQLCoreOperations[TenantStatus] | TenantStatus` in function `models.account.Tenant.__init__` [bad-argument-type]
   --> tests/test_containers_integration_tests/controllers/console/helpers.py:40:48
 ERROR `SimpleNamespace` is not assignable to attribute `mcp_ns` with type `Namespace` [bad-assignment]

@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-04-10 06:32:42.996955079 +0000
+++ /tmp/pyrefly_pr.txt	2026-04-10 06:32:33.405965422 +0000
@@ -1,7 +1,7 @@
 ERROR Object of class `App` has no attribute `access_mode` [missing-attribute]
    --> controllers/console/app/app.py:561:13
 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
+  --> controllers/console/auth/email_register.py:75:108
 ERROR Object of class `MissingRouter` has no attribute `get` [missing-attribute]
   --> controllers/console/init_validate.py:31:2
 ERROR Object of class `MissingRouter` has no attribute `post` [missing-attribute]
@@ -316,7 +316,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:1153:13
+    --> services/account_service.py:1154:13
 ERROR No matching overload found for function `flask.helpers.stream_with_context` called with arguments: (Generator[bytes]) [no-matching-overload]
    --> services/audio_service.py:144:56
 ERROR No matching overload found for function `flask.helpers.stream_with_context` called with arguments: (Generator[bytes]) [no-matching-overload]
@@ -577,10 +577,16 @@
    --> tests/test_containers_integration_tests/controllers/console/app/test_app_apis.py:600:51
 ERROR Argument `Literal['normal']` is not assignable to parameter `status` with type `SQLCoreOperations[TenantStatus] | TenantStatus` in function `models.account.Tenant.__init__` [bad-argument-type]
   --> tests/test_containers_integration_tests/controllers/console/app/test_chat_conversation_status_count_api.py:33:48
+ERROR Unexpected keyword argument `session` in function `services.account_service.AccountService.get_account_by_email_with_case_fallback` [unexpected-keyword]
+   --> tests/test_containers_integration_tests/controllers/console/auth/test_email_register.py:161:86
+ERROR Unexpected keyword argument `session` in function `services.account_service.AccountService.get_account_by_email_with_case_fallback` [unexpected-keyword]
+   --> tests/test_containers_integration_tests/controllers/console/auth/test_forgot_password.py:164:87
 ERROR Object of class `RequestError` has no attribute `response` [missing-attribute]
    --> tests/test_containers_integration_tests/controllers/console/auth/test_oauth.py:196:9
 ERROR Object of class `RequestError` has no attribute `response` [missing-attribute]
    --> tests/test_containers_integration_tests/controllers/console/auth/test_oauth.py:197:9
+ERROR Unexpected keyword argument `session` in function `services.account_service.AccountService.get_account_by_email_with_case_fallback` [unexpected-keyword]
+   --> tests/test_containers_integration_tests/controllers/console/auth/test_oauth.py:440:90
 ERROR Argument `Literal['normal']` is not assignable to parameter `status` with type `SQLCoreOperations[TenantStatus] | TenantStatus` in function `models.account.Tenant.__init__` [bad-argument-type]
   --> tests/test_containers_integration_tests/controllers/console/helpers.py:40:48
 ERROR `SimpleNamespace` is not assignable to attribute `mcp_ns` with type `Namespace` [bad-assignment]

@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-04-10 06:50:30.523858547 +0000
+++ /tmp/pyrefly_pr.txt	2026-04-10 06:50:20.561814991 +0000
@@ -1,7 +1,7 @@
 ERROR Object of class `App` has no attribute `access_mode` [missing-attribute]
    --> controllers/console/app/app.py:561:13
 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
+  --> controllers/console/auth/email_register.py:76:108
 ERROR Object of class `MissingRouter` has no attribute `get` [missing-attribute]
   --> controllers/console/init_validate.py:31:2
 ERROR Object of class `MissingRouter` has no attribute `post` [missing-attribute]
@@ -316,7 +316,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:1153:13
+    --> services/account_service.py:1154:13
 ERROR No matching overload found for function `flask.helpers.stream_with_context` called with arguments: (Generator[bytes]) [no-matching-overload]
    --> services/audio_service.py:144:56
 ERROR No matching overload found for function `flask.helpers.stream_with_context` called with arguments: (Generator[bytes]) [no-matching-overload]
@@ -1182,9 +1182,9 @@
 ERROR Argument `Literal['normal']` is not assignable to parameter `status` with type `SQLCoreOperations[TenantStatus] | TenantStatus` in function `models.account.Tenant.__init__` [bad-argument-type]
    --> tests/test_containers_integration_tests/services/test_webapp_auth_service.py:142:20
 ERROR Argument `Literal['active']` is not assignable to parameter `status` with type `AccountStatus | SQLCoreOperations[AccountStatus]` in function `models.account.Account.__init__` [bad-argument-type]
-   --> tests/test_containers_integration_tests/services/test_webapp_auth_service.py:346:20
+   --> tests/test_containers_integration_tests/services/test_webapp_auth_service.py:345:20
 ERROR Argument `Literal['normal']` is not assignable to parameter `status` with type `SQLCoreOperations[TenantStatus] | TenantStatus` in function `models.account.Tenant.__init__` [bad-argument-type]
-   --> tests/test_containers_integration_tests/services/test_webapp_auth_service.py:717:20
+   --> tests/test_containers_integration_tests/services/test_webapp_auth_service.py:715:20
 ERROR Argument `dict[str, dict[str, list[dict[str, bool | str]] | str]]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.webhook_service.WebhookService.extract_and_validate_webhook_data` [bad-argument-type]
    --> tests/test_containers_integration_tests/services/test_webhook_service.py:288:88
 ERROR Argument `dict[str, dict[str, str]]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.webhook_service.WebhookService.extract_and_validate_webhook_data` [bad-argument-type]

@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-04-10 06:52:17.249908860 +0000
+++ /tmp/pyrefly_pr.txt	2026-04-10 06:52:09.097026953 +0000
@@ -1,7 +1,7 @@
 ERROR Object of class `App` has no attribute `access_mode` [missing-attribute]
    --> controllers/console/app/app.py:561:13
 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
+  --> controllers/console/auth/email_register.py:75:108
 ERROR Object of class `MissingRouter` has no attribute `get` [missing-attribute]
   --> controllers/console/init_validate.py:31:2
 ERROR Object of class `MissingRouter` has no attribute `post` [missing-attribute]
@@ -316,7 +316,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:1153:13
+    --> services/account_service.py:1154:13
 ERROR No matching overload found for function `flask.helpers.stream_with_context` called with arguments: (Generator[bytes]) [no-matching-overload]
    --> services/audio_service.py:144:56
 ERROR No matching overload found for function `flask.helpers.stream_with_context` called with arguments: (Generator[bytes]) [no-matching-overload]
@@ -1182,9 +1182,9 @@
 ERROR Argument `Literal['normal']` is not assignable to parameter `status` with type `SQLCoreOperations[TenantStatus] | TenantStatus` in function `models.account.Tenant.__init__` [bad-argument-type]
    --> tests/test_containers_integration_tests/services/test_webapp_auth_service.py:142:20
 ERROR Argument `Literal['active']` is not assignable to parameter `status` with type `AccountStatus | SQLCoreOperations[AccountStatus]` in function `models.account.Account.__init__` [bad-argument-type]
-   --> tests/test_containers_integration_tests/services/test_webapp_auth_service.py:346:20
+   --> tests/test_containers_integration_tests/services/test_webapp_auth_service.py:345:20
 ERROR Argument `Literal['normal']` is not assignable to parameter `status` with type `SQLCoreOperations[TenantStatus] | TenantStatus` in function `models.account.Tenant.__init__` [bad-argument-type]
-   --> tests/test_containers_integration_tests/services/test_webapp_auth_service.py:717:20
+   --> tests/test_containers_integration_tests/services/test_webapp_auth_service.py:715:20
 ERROR Argument `dict[str, dict[str, list[dict[str, bool | str]] | str]]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.webhook_service.WebhookService.extract_and_validate_webhook_data` [bad-argument-type]
    --> tests/test_containers_integration_tests/services/test_webhook_service.py:288:88
 ERROR Argument `dict[str, dict[str, str]]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.webhook_service.WebhookService.extract_and_validate_webhook_data` [bad-argument-type]

@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-04-10 07:03:59.048554243 +0000
+++ /tmp/pyrefly_pr.txt	2026-04-10 07:03:50.675579151 +0000
@@ -1,7 +1,7 @@
 ERROR Object of class `App` has no attribute `access_mode` [missing-attribute]
    --> controllers/console/app/app.py:561:13
 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
+  --> controllers/console/auth/email_register.py:76:108
 ERROR Object of class `MissingRouter` has no attribute `get` [missing-attribute]
   --> controllers/console/init_validate.py:31:2
 ERROR Object of class `MissingRouter` has no attribute `post` [missing-attribute]
@@ -316,7 +316,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:1153:13
+    --> services/account_service.py:1154:13
 ERROR No matching overload found for function `flask.helpers.stream_with_context` called with arguments: (Generator[bytes]) [no-matching-overload]
    --> services/audio_service.py:144:56
 ERROR No matching overload found for function `flask.helpers.stream_with_context` called with arguments: (Generator[bytes]) [no-matching-overload]
@@ -1182,9 +1182,9 @@
 ERROR Argument `Literal['normal']` is not assignable to parameter `status` with type `SQLCoreOperations[TenantStatus] | TenantStatus` in function `models.account.Tenant.__init__` [bad-argument-type]
    --> tests/test_containers_integration_tests/services/test_webapp_auth_service.py:142:20
 ERROR Argument `Literal['active']` is not assignable to parameter `status` with type `AccountStatus | SQLCoreOperations[AccountStatus]` in function `models.account.Account.__init__` [bad-argument-type]
-   --> tests/test_containers_integration_tests/services/test_webapp_auth_service.py:346:20
+   --> tests/test_containers_integration_tests/services/test_webapp_auth_service.py:345:20
 ERROR Argument `Literal['normal']` is not assignable to parameter `status` with type `SQLCoreOperations[TenantStatus] | TenantStatus` in function `models.account.Tenant.__init__` [bad-argument-type]
-   --> tests/test_containers_integration_tests/services/test_webapp_auth_service.py:717:20
+   --> tests/test_containers_integration_tests/services/test_webapp_auth_service.py:715:20
 ERROR Argument `dict[str, dict[str, list[dict[str, bool | str]] | str]]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.webhook_service.WebhookService.extract_and_validate_webhook_data` [bad-argument-type]
    --> tests/test_containers_integration_tests/services/test_webhook_service.py:288:88
 ERROR Argument `dict[str, dict[str, str]]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.webhook_service.WebhookService.extract_and_validate_webhook_data` [bad-argument-type]

@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-04-10 07:06:04.726860658 +0000
+++ /tmp/pyrefly_pr.txt	2026-04-10 07:05:55.282623930 +0000
@@ -1,7 +1,7 @@
 ERROR Object of class `App` has no attribute `access_mode` [missing-attribute]
    --> controllers/console/app/app.py:561:13
 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
+  --> controllers/console/auth/email_register.py:75:108
 ERROR Object of class `MissingRouter` has no attribute `get` [missing-attribute]
   --> controllers/console/init_validate.py:31:2
 ERROR Object of class `MissingRouter` has no attribute `post` [missing-attribute]
@@ -316,7 +316,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:1153:13
+    --> services/account_service.py:1154:13
 ERROR No matching overload found for function `flask.helpers.stream_with_context` called with arguments: (Generator[bytes]) [no-matching-overload]
    --> services/audio_service.py:144:56
 ERROR No matching overload found for function `flask.helpers.stream_with_context` called with arguments: (Generator[bytes]) [no-matching-overload]
@@ -1182,9 +1182,9 @@
 ERROR Argument `Literal['normal']` is not assignable to parameter `status` with type `SQLCoreOperations[TenantStatus] | TenantStatus` in function `models.account.Tenant.__init__` [bad-argument-type]
    --> tests/test_containers_integration_tests/services/test_webapp_auth_service.py:142:20
 ERROR Argument `Literal['active']` is not assignable to parameter `status` with type `AccountStatus | SQLCoreOperations[AccountStatus]` in function `models.account.Account.__init__` [bad-argument-type]
-   --> tests/test_containers_integration_tests/services/test_webapp_auth_service.py:346:20
+   --> tests/test_containers_integration_tests/services/test_webapp_auth_service.py:345:20
 ERROR Argument `Literal['normal']` is not assignable to parameter `status` with type `SQLCoreOperations[TenantStatus] | TenantStatus` in function `models.account.Tenant.__init__` [bad-argument-type]
-   --> tests/test_containers_integration_tests/services/test_webapp_auth_service.py:717:20
+   --> tests/test_containers_integration_tests/services/test_webapp_auth_service.py:715:20
 ERROR Argument `dict[str, dict[str, list[dict[str, bool | str]] | str]]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.webhook_service.WebhookService.extract_and_validate_webhook_data` [bad-argument-type]
    --> tests/test_containers_integration_tests/services/test_webhook_service.py:288:88
 ERROR Argument `dict[str, dict[str, str]]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.webhook_service.WebhookService.extract_and_validate_webhook_data` [bad-argument-type]

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Apr 10, 2026
@asukaminato0721 asukaminato0721 added this pull request to the merge queue Apr 10, 2026
Merged via the queue into langgenius:main with commit bcd738d Apr 10, 2026
27 checks passed
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 size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_account_by_email_with_case_fallback lead account detach instance error

2 participants