current_user error #13205

Closed
opened 2026-02-21 19:11:04 -05:00 by yindo · 3 comments
Owner

Originally created by @2495710777 on GitHub (Apr 22, 2025).

Self Checks

  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Provide a description of requested docs changes

When using current_user in the dify node, when multiple nodes are running in parallel, current_user will become None, resulting in an error. There is no problem with single-node execution

Image

Originally created by @2495710777 on GitHub (Apr 22, 2025). ### Self Checks - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Provide a description of requested docs changes When using current_user in the dify node, when multiple nodes are running in parallel, current_user will become None, resulting in an error. There is no problem with single-node execution ![Image](https://github.com/user-attachments/assets/43659b33-e7be-4598-bb78-45fefb3d1eaa) <!-- Failed to upload "20250422-151739.jpg" -->
yindo added the 🐞 bug label 2026-02-21 19:11:04 -05:00
yindo closed this issue 2026-02-21 19:11:04 -05:00
Author
Owner

@2495710777 commented on GitHub (Apr 22, 2025):

'NoneType' object has no attribute 'current_tenant'

@2495710777 commented on GitHub (Apr 22, 2025): 'NoneType' object has no attribute 'current_tenant'
Author
Owner

@crazywoola commented on GitHub (Apr 22, 2025):

For bug report please use the bug report template, also the version number is required.

@crazywoola commented on GitHub (Apr 22, 2025): For bug report please use the bug report template, also the version number is required.
Author
Owner

@dosubot[bot] commented on GitHub (Apr 22, 2025):

Hello @2495710777! I'm Dosu, your friendly bot here to help tackle bugs, answer questions, and assist you in becoming a contributor while we wait for a human maintainer. Let's get started!

The issue you're encountering with current_user becoming None during parallel node execution in the Dify platform could be related to how user sessions are managed across multiple nodes. In a multi-node environment, session data might not be shared correctly between nodes, leading to current_user being None.

Here are a few potential areas to investigate:

  1. Session Management: Ensure that your session management is configured to work across multiple nodes. This typically involves using a shared session store, such as a database or a distributed cache like Redis, to maintain session consistency across nodes.

  2. Flask-Login Configuration: Check the configuration of flask_login to ensure it is set up to handle sessions in a distributed environment. This might involve setting the SESSION_TYPE to a shared backend and ensuring that the session data is correctly serialized and deserialized.

  3. Load Balancer Sticky Sessions: If you're using a load balancer, ensure that sticky sessions (session affinity) are enabled. This ensures that requests from the same user are consistently routed to the same node, which can help maintain session state.

  4. Debugging and Logging: Add logging around the areas where current_user is accessed to help identify when and why it becomes None. This can provide insights into whether the issue is with session retrieval or another part of the code.

These steps should help you diagnose and potentially resolve the issue with current_user in a multi-node setup.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (Apr 22, 2025): <!-- Greeting --> Hello @2495710777! I'm [Dosu](https://dosu.dev), your friendly bot here to help tackle bugs, answer questions, and assist you in becoming a contributor while we wait for a human maintainer. Let's get started! <!-- Answer --> The issue you're encountering with `current_user` becoming `None` during parallel node execution in the Dify platform could be related to how user sessions are managed across multiple nodes. In a multi-node environment, session data might not be shared correctly between nodes, leading to `current_user` being `None`. Here are a few potential areas to investigate: 1. **Session Management**: Ensure that your session management is configured to work across multiple nodes. This typically involves using a shared session store, such as a database or a distributed cache like Redis, to maintain session consistency across nodes. 2. **Flask-Login Configuration**: Check the configuration of `flask_login` to ensure it is set up to handle sessions in a distributed environment. This might involve setting the `SESSION_TYPE` to a shared backend and ensuring that the session data is correctly serialized and deserialized. 3. **Load Balancer Sticky Sessions**: If you're using a load balancer, ensure that sticky sessions (session affinity) are enabled. This ensures that requests from the same user are consistently routed to the same node, which can help maintain session state. 4. **Debugging and Logging**: Add logging around the areas where `current_user` is accessed to help identify when and why it becomes `None`. This can provide insights into whether the issue is with session retrieval or another part of the code. These steps should help you diagnose and potentially resolve the issue with `current_user` in a multi-node setup. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/3a6d9b17-6adf-4f6a-91a3-fa6670bbf67c?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/3a6d9b17-6adf-4f6a-91a3-fa6670bbf67c?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/3a6d9b17-6adf-4f6a-91a3-fa6670bbf67c?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/3a6d9b17-6adf-4f6a-91a3-fa6670bbf67c?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/3a6d9b17-6adf-4f6a-91a3-fa6670bbf67c?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/3a6d9b17-6adf-4f6a-91a3-fa6670bbf67c?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/3a6d9b17-6adf-4f6a-91a3-fa6670bbf67c?feedback_type=other)</sup>
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#13205