AttributeError: 'EndUser' object has no attribute 'current_tenant_id' #14247

Closed
opened 2026-02-21 19:16:20 -05:00 by yindo · 2 comments
Owner

Originally created by @912988434 on GitHub (May 27, 2025).

Originally assigned to: @laipz8200 on GitHub.

Self Checks

  • 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 (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.4.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

An "Internal Server Error" occurred when using the API to request the self hosted of the Dify interface, with code "unknown".
curl -X GET 'https://dify.xxxx.com/v1/conversations?user="xxxx"&limit=20' --header 'Authorization: Bearer xxxxx'
{"message": "Internal Server Error", "code": "unknown"}
api error:

Image

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @912988434 on GitHub (May 27, 2025). Originally assigned to: @laipz8200 on GitHub. ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [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 this 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. ### Dify version 1.4.1 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce An "Internal Server Error" occurred when using the API to request the self hosted of the Dify interface, with code "unknown". curl -X GET '[https://dify.xxxx.com/v1/conversations?user="xxxx"&limit=20](https://dify.xxxx.com/v1/conversations?user=%22xxxx%22&limit=20)' --header 'Authorization: Bearer xxxxx' {"message": "Internal Server Error", "code": "unknown"} api error: <img width="998" alt="Image" src="https://github.com/user-attachments/assets/e771c3f5-613e-43dd-ac16-b11a7f1f4acf" /> ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug label 2026-02-21 19:16:20 -05:00
yindo closed this issue 2026-02-21 19:16:20 -05:00
Author
Owner

@crazywoola commented on GitHub (May 27, 2025):

Link https://github.com/langgenius/dify/pull/20304

@crazywoola commented on GitHub (May 27, 2025): Link https://github.com/langgenius/dify/pull/20304
Author
Owner

@dosubot[bot] commented on GitHub (May 28, 2025):

The error 'AttributeError: 'EndUser' object has no attribute 'current_tenant_id' occurs because, in the Dify codebase, EndUser objects use the attribute tenant_id, not current_tenant_id. The current_tenant_id attribute is only present on Account objects. When the code tries to access current_tenant_id on an EndUser, it raises this error.

To resolve this, ensure that anywhere your code or configuration accesses the tenant ID for an EndUser, it uses user.tenant_id instead of user.current_tenant_id. For example, the codebase handles this distinction as follows:

if isinstance(user, Account):
    current_tenant_id = user.current_tenant_id
else:
    # end_user
    current_tenant_id = user.tenant_id

source

You should review any customizations, plugins, or API calls in your deployment that might be incorrectly referencing current_tenant_id on an EndUser. Also, check any initialization logic to ensure the correct user type and attribute are being used.

There are no existing issues or discussions in the Dify repository that specifically address this error. If you continue to encounter problems after making these changes, please provide more details about where in your setup the error occurs, and I can help you further.

To reply, just mention my name @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Join Discord Share on X

@dosubot[bot] commented on GitHub (May 28, 2025): <!-- Answer --> The error `'AttributeError: 'EndUser' object has no attribute 'current_tenant_id'` occurs because, in the Dify codebase, `EndUser` objects use the attribute `tenant_id`, not `current_tenant_id`. The `current_tenant_id` attribute is only present on `Account` objects. When the code tries to access `current_tenant_id` on an `EndUser`, it raises this error. To resolve this, ensure that anywhere your code or configuration accesses the tenant ID for an `EndUser`, it uses `user.tenant_id` instead of `user.current_tenant_id`. For example, the codebase handles this distinction as follows: ```python if isinstance(user, Account): current_tenant_id = user.current_tenant_id else: # end_user current_tenant_id = user.tenant_id ``` [source](https://github.com/langgenius/dify/blob/main/api/services/file_service.py) You should review any customizations, plugins, or API calls in your deployment that might be incorrectly referencing `current_tenant_id` on an `EndUser`. Also, check any initialization logic to ensure the correct user type and attribute are being used. There are no existing issues or discussions in the Dify repository that specifically address this error. If you continue to encounter problems after making these changes, please provide more details about where in your setup the error occurs, and I can help you further. <!-- Dosu Comment Footer --> *To reply, just mention my name [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/904b62e1-75f7-4152-80cb-b1ad122ceee4?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/904b62e1-75f7-4152-80cb-b1ad122ceee4?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/904b62e1-75f7-4152-80cb-b1ad122ceee4?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/904b62e1-75f7-4152-80cb-b1ad122ceee4?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/904b62e1-75f7-4152-80cb-b1ad122ceee4?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/904b62e1-75f7-4152-80cb-b1ad122ceee4?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/904b62e1-75f7-4152-80cb-b1ad122ceee4?feedback_type=other)</sup>&nbsp;&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/20343)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#14247