dify - 💡(How to fix) Fix [BUG] Internal Server Error when using Reset Password feature [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
langgenius/dify#35518Fetched 2026-04-24 06:14:17
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
1
Author
Timeline (top)
commented ×1labeled ×1mentioned ×1subscribed ×1

Error Message

I am currently using version 1.13.1. When I attempt to use the 'Forgot your password?' feature, I immediately receive an 'Internal Server Error'. api-1 | 2026-04-23 06:56:21.134 ERROR [Dummy-70] [app.py:875] 9116e6bb437c52b29115c933d37da3f7 - Exception on /console/api/forgot-password [POST] api-1 | Traceback (most recent call last): api-1 | sqlalchemy.orm.exc.DetachedInstanceError: Instance <Account at 0xffff54e7f1d0> is not bound to a Session; attribute refresh operation cannot proceed (Background on this error at: https://sqlalche.me/e/20/bhk3) error report: Internal Server Error

Fix Action

Fix / Workaround

I am currently using version 1.13.1. When I attempt to use the 'Forgot your password?' feature, I immediately receive an 'Internal Server Error'. [root@Node2 docker]# docker-compose logs -f api api-1 | 2026-04-23 06:56:13.177 INFO [Dummy-63] [_client.py:1025] a571779e6b655158b135e100f9218a32 - HTTP Request: GET http://plugin_daemon:5002/plugin/1bebe67d-5198-4a56-8d17-2b1edb3455f2/management/models?page=1&page_size=256 "HTTP/1.1 200 OK" api-1 | 2026-04-23 06:56:13.178 INFO [Dummy-64] [_client.py:1025] 5ae7085eb95b5898a59ae836b99f6d2b - HTTP Request: GET http://plugin_daemon:5002/plugin/1bebe67d-5198-4a56-8d17-2b1edb3455f2/management/models?page=1&page_size=256 "HTTP/1.1 200 OK" api-1 | 2026-04-23 06:56:13.326 INFO [Dummy-65] [_client.py:1025] abdffad8a9b85669ae3d65b23dbca9f6 - HTTP Request: GET http://plugin_daemon:5002/plugin/1bebe67d-5198-4a56-8d17-2b1edb3455f2/management/models?page=1&page_size=256 "HTTP/1.1 200 OK" api-1 | 2026-04-23 06:56:13.335 INFO [Dummy-66] [_client.py:1025] 7ccc7fa3d2725f16a735d16e4cb0de3d - HTTP Request: GET http://plugin_daemon:5002/plugin/1bebe67d-5198-4a56-8d17-2b1edb3455f2/management/models?page=1&page_size=256 "HTTP/1.1 200 OK" api-1 | 2026-04-23 06:56:13.465 INFO [Dummy-67] [_client.py:1025] 14ceb48ea64050e29cdeb8d827642883 - HTTP Request: GET http://plugin_daemon:5002/plugin/1bebe67d-5198-4a56-8d17-2b1edb3455f2/management/install/tasks?page=1&page_size=100 "HTTP/1.1 200 OK" api-1 | 2026-04-23 06:56:13.548 INFO [Dummy-68] [_client.py:1025] 66412559ee0a5ac7b8af931ce8a676b7 - HTTP Request: GET http://plugin_daemon:5002/plugin/1bebe67d-5198-4a56-8d17-2b1edb3455f2/management/models?page=1&page_size=256 "HTTP/1.1 200 OK" api-1 | 2026-04-23 06:56:14.384 INFO [Dummy-69] [client.py:1025] f606795ca76c5bc097b52fbcbd5d330b - HTTP Request: GET https://updates.dify.ai?current_version=1.13.3 "HTTP/1.1 200 OK" api-1 | 2026-04-23 06:56:21.134 ERROR [Dummy-70] [app.py:875] 9116e6bb437c52b29115c933d37da3f7 - Exception on /console/api/forgot-password [POST] api-1 | Traceback (most recent call last): api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 917, in full_dispatch_request api-1 | rv = self.dispatch_request() api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 902, in dispatch_request api-1 | return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return] api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask_restx/api.py", line 404, in wrapper api-1 | resp = resource(*args, **kwargs) api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask/views.py", line 110, in view api-1 | return current_app.ensure_sync(self.dispatch_request)(**kwargs) # type: ignore[no-any-return] api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask_restx/resource.py", line 41, in dispatch_request api-1 | resp = meth(*args, **kwargs) api-1 | ^^^^^^^^^^^^^^^^^^^^^ api-1 | File "/app/api/controllers/console/wraps.py", line 227, in decorated api-1 | return view(*args, **kwargs) api-1 | ^^^^^^^^^^^^^^^^^^^^^ api-1 | File "/app/api/controllers/console/wraps.py", line 249, in decorated api-1 | return view(*args, **kwargs) api-1 | ^^^^^^^^^^^^^^^^^^^^^ api-1 | File "/app/api/controllers/console/auth/forgot_password.py", line 108, in post api-1 | token = AccountService.send_reset_password_email( api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ api-1 | File "/app/api/services/account_service.py", line 481, in send_reset_password_email api-1 | account_email = account.email if account else email api-1 | ^^^^^^^^^^^^^ api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/orm/attributes.py", line 569, in get api-1 | return self.impl.get(state, dict) # type: ignore[no-any-return] api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/orm/attributes.py", line 1096, in get api-1 | value = self._fire_loader_callables(state, key, passive) api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/orm/attributes.py", line 1126, in _fire_loader_callables api-1 | return state._load_expired(state, passive) api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/orm/state.py", line 828, in _load_expired api-1 | self.manager.expired_attribute_loader(self, toload, passive) api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/orm/loading.py", line 1607, in load_scalar_attributes api-1 | raise orm_exc.DetachedInstanceError( api-1 | sqlalchemy.orm.exc.DetachedInstanceError: Instance <Account at 0xffff54e7f1d0> is not bound to a Session; attribute refresh operation cannot proceed (Background on this error at: https://sqlalche.me/e/20/bhk3)

RAW_BUFFERClick to expand / collapse

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.13.3

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

I am currently using version 1.13.1. When I attempt to use the 'Forgot your password?' feature, I immediately receive an 'Internal Server Error'. [root@Node2 docker]# docker-compose logs -f api api-1 | 2026-04-23 06:56:13.177 INFO [Dummy-63] [_client.py:1025] a571779e6b655158b135e100f9218a32 - HTTP Request: GET http://plugin_daemon:5002/plugin/1bebe67d-5198-4a56-8d17-2b1edb3455f2/management/models?page=1&page_size=256 "HTTP/1.1 200 OK" api-1 | 2026-04-23 06:56:13.178 INFO [Dummy-64] [_client.py:1025] 5ae7085eb95b5898a59ae836b99f6d2b - HTTP Request: GET http://plugin_daemon:5002/plugin/1bebe67d-5198-4a56-8d17-2b1edb3455f2/management/models?page=1&page_size=256 "HTTP/1.1 200 OK" api-1 | 2026-04-23 06:56:13.326 INFO [Dummy-65] [_client.py:1025] abdffad8a9b85669ae3d65b23dbca9f6 - HTTP Request: GET http://plugin_daemon:5002/plugin/1bebe67d-5198-4a56-8d17-2b1edb3455f2/management/models?page=1&page_size=256 "HTTP/1.1 200 OK" api-1 | 2026-04-23 06:56:13.335 INFO [Dummy-66] [_client.py:1025] 7ccc7fa3d2725f16a735d16e4cb0de3d - HTTP Request: GET http://plugin_daemon:5002/plugin/1bebe67d-5198-4a56-8d17-2b1edb3455f2/management/models?page=1&page_size=256 "HTTP/1.1 200 OK" api-1 | 2026-04-23 06:56:13.465 INFO [Dummy-67] [_client.py:1025] 14ceb48ea64050e29cdeb8d827642883 - HTTP Request: GET http://plugin_daemon:5002/plugin/1bebe67d-5198-4a56-8d17-2b1edb3455f2/management/install/tasks?page=1&page_size=100 "HTTP/1.1 200 OK" api-1 | 2026-04-23 06:56:13.548 INFO [Dummy-68] [_client.py:1025] 66412559ee0a5ac7b8af931ce8a676b7 - HTTP Request: GET http://plugin_daemon:5002/plugin/1bebe67d-5198-4a56-8d17-2b1edb3455f2/management/models?page=1&page_size=256 "HTTP/1.1 200 OK" api-1 | 2026-04-23 06:56:14.384 INFO [Dummy-69] [client.py:1025] f606795ca76c5bc097b52fbcbd5d330b - HTTP Request: GET https://updates.dify.ai?current_version=1.13.3 "HTTP/1.1 200 OK" api-1 | 2026-04-23 06:56:21.134 ERROR [Dummy-70] [app.py:875] 9116e6bb437c52b29115c933d37da3f7 - Exception on /console/api/forgot-password [POST] api-1 | Traceback (most recent call last): api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 917, in full_dispatch_request api-1 | rv = self.dispatch_request() api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 902, in dispatch_request api-1 | return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return] api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask_restx/api.py", line 404, in wrapper api-1 | resp = resource(*args, **kwargs) api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask/views.py", line 110, in view api-1 | return current_app.ensure_sync(self.dispatch_request)(**kwargs) # type: ignore[no-any-return] api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask_restx/resource.py", line 41, in dispatch_request api-1 | resp = meth(*args, **kwargs) api-1 | ^^^^^^^^^^^^^^^^^^^^^ api-1 | File "/app/api/controllers/console/wraps.py", line 227, in decorated api-1 | return view(*args, **kwargs) api-1 | ^^^^^^^^^^^^^^^^^^^^^ api-1 | File "/app/api/controllers/console/wraps.py", line 249, in decorated api-1 | return view(*args, **kwargs) api-1 | ^^^^^^^^^^^^^^^^^^^^^ api-1 | File "/app/api/controllers/console/auth/forgot_password.py", line 108, in post api-1 | token = AccountService.send_reset_password_email( api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ api-1 | File "/app/api/services/account_service.py", line 481, in send_reset_password_email api-1 | account_email = account.email if account else email api-1 | ^^^^^^^^^^^^^ api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/orm/attributes.py", line 569, in get api-1 | return self.impl.get(state, dict) # type: ignore[no-any-return] api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/orm/attributes.py", line 1096, in get api-1 | value = self._fire_loader_callables(state, key, passive) api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/orm/attributes.py", line 1126, in _fire_loader_callables api-1 | return state._load_expired(state, passive) api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/orm/state.py", line 828, in _load_expired api-1 | self.manager.expired_attribute_loader(self, toload, passive) api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/orm/loading.py", line 1607, in load_scalar_attributes api-1 | raise orm_exc.DetachedInstanceError( api-1 | sqlalchemy.orm.exc.DetachedInstanceError: Instance <Account at 0xffff54e7f1d0> is not bound to a Session; attribute refresh operation cannot proceed (Background on this error at: https://sqlalche.me/e/20/bhk3)

✔️ Expected Behavior

After clicking "Forgot your password?", the user should be able to enter their email address. The system should successfully send a reset link or verification code to the user's email. The page should then redirect to the verification code input screen.

❌ Actual Behavior

error report: Internal Server Error

extent analysis

TL;DR

The issue is likely due to a detached instance error in the SQLAlchemy ORM, which can be resolved by ensuring the account instance is properly bound to a session before attempting to access its attributes.

Guidance

  • Verify that the AccountService is properly handling sessions and ensuring that the account instance is bound to a session before calling send_reset_password_email.
  • Check the account_service.py file, specifically the send_reset_password_email method, to ensure that the account instance is being properly retrieved and bound to a session.
  • Consider adding error handling to catch and handle DetachedInstanceError exceptions, which may indicate a larger issue with session management.
  • Review the SQLAlchemy documentation on detached instances and session management to ensure that the application is properly handling these concepts.

Example

# Example of ensuring an account instance is bound to a session
from sqlalchemy.orm import sessionmaker

Session = sessionmaker(bind=engine)
session = Session()

account = session.query(Account).get(account_id)
# Ensure the account instance is bound to the session
session.add(account)

Notes

The provided stacktrace and code snippets suggest that the issue is related to SQLAlchemy's ORM and session management. However, without more context or information about the application's architecture, it is difficult to provide a more specific solution.

Recommendation

Apply a workaround by ensuring that the account instance is properly bound to a session before attempting to access its attributes, as this is the most likely cause of the detached instance error.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING