Agent cannot send image #6300

Closed
opened 2026-02-21 18:15:03 -05:00 by yindo · 2 comments
Owner

Originally created by @louisLiu1004 on GitHub (Oct 24, 2024).

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

0.10.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

upload image to talk in agent

✔️ Expected Behavior

No response

Actual Behavior

image

Traceback (most recent call last):
  File "/app/api/controllers/console/app/completion.py", line 123, in post
    response = AppGenerateService.generate(
  File "/app/api/services/app_generate_service.py", line 53, in generate
    AgentChatAppGenerator().generate(
  File "/app/api/core/app/apps/agent_chat/app_generator.py", line 154, in generate
    (conversation, message) = self._init_generate_records(application_generate_entity, conversation)
  File "/app/api/core/app/apps/message_based_app_generator.py", line 236, in _init_generate_records
    message_file = MessageFile(
  File "<string>", line 4, in __init__
  File "/app/api/.venv/lib/python3.10/site-packages/sqlalchemy/orm/state.py", line 571, in _initialize_instance
    with util.safe_reraise():
  File "/app/api/.venv/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/app/api/.venv/lib/python3.10/site-packages/sqlalchemy/orm/state.py", line 569, in _initialize_instance
    manager.original_init(*mixed[1:], **kwargs)
  File "/app/api/models/model.py", line 1112, in __init__
    self.created_by_role = created_by_role.value
AttributeError: 'str' object has no attribute 'value'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/api/.venv/lib/python3.10/site-packages/flask/app.py", line 880, in full_dispatch_request
    rv = self.dispatch_request()
  File "/app/api/.venv/lib/python3.10/site-packages/flask/app.py", line 865, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
  File "/app/api/.venv/lib/python3.10/site-packages/flask_restful/__init__.py", line 489, in wrapper
    resp = resource(*args, **kwargs)
  File "/app/api/.venv/lib/python3.10/site-packages/flask/views.py", line 110, in view
    return current_app.ensure_sync(self.dispatch_request)(**kwargs)  # type: ignore[no-any-return]
  File "/app/api/.venv/lib/python3.10/site-packages/flask_restful/__init__.py", line 604, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/app/api/controllers/console/setup.py", line 65, in decorated
    return view(*args, **kwargs)
  File "/app/api/libs/login.py", line 92, in decorated_view
    return current_app.ensure_sync(func)(*args, **kwargs)
  File "/app/api/controllers/console/wraps.py", line 22, in decorated
    return view(*args, **kwargs)
  File "/app/api/controllers/console/app/wraps.py", line 49, in decorated_view
    return view_func(*args, **kwargs)
  File "/app/api/controllers/console/app/completion.py", line 149, in post
    raise InternalServerError()
werkzeug.exceptions.InternalServerError: 500 Internal Server Error: The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.
Originally created by @louisLiu1004 on GitHub (Oct 24, 2024). ### 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 0.10.1 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce upload image to talk in agent ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior ![image](https://github.com/user-attachments/assets/e0786be4-8555-4aa7-9268-8ead3f3e889f) ``` Traceback (most recent call last): File "/app/api/controllers/console/app/completion.py", line 123, in post response = AppGenerateService.generate( File "/app/api/services/app_generate_service.py", line 53, in generate AgentChatAppGenerator().generate( File "/app/api/core/app/apps/agent_chat/app_generator.py", line 154, in generate (conversation, message) = self._init_generate_records(application_generate_entity, conversation) File "/app/api/core/app/apps/message_based_app_generator.py", line 236, in _init_generate_records message_file = MessageFile( File "<string>", line 4, in __init__ File "/app/api/.venv/lib/python3.10/site-packages/sqlalchemy/orm/state.py", line 571, in _initialize_instance with util.safe_reraise(): File "/app/api/.venv/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__ raise exc_value.with_traceback(exc_tb) File "/app/api/.venv/lib/python3.10/site-packages/sqlalchemy/orm/state.py", line 569, in _initialize_instance manager.original_init(*mixed[1:], **kwargs) File "/app/api/models/model.py", line 1112, in __init__ self.created_by_role = created_by_role.value AttributeError: 'str' object has no attribute 'value' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/app/api/.venv/lib/python3.10/site-packages/flask/app.py", line 880, in full_dispatch_request rv = self.dispatch_request() File "/app/api/.venv/lib/python3.10/site-packages/flask/app.py", line 865, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return] File "/app/api/.venv/lib/python3.10/site-packages/flask_restful/__init__.py", line 489, in wrapper resp = resource(*args, **kwargs) File "/app/api/.venv/lib/python3.10/site-packages/flask/views.py", line 110, in view return current_app.ensure_sync(self.dispatch_request)(**kwargs) # type: ignore[no-any-return] File "/app/api/.venv/lib/python3.10/site-packages/flask_restful/__init__.py", line 604, in dispatch_request resp = meth(*args, **kwargs) File "/app/api/controllers/console/setup.py", line 65, in decorated return view(*args, **kwargs) File "/app/api/libs/login.py", line 92, in decorated_view return current_app.ensure_sync(func)(*args, **kwargs) File "/app/api/controllers/console/wraps.py", line 22, in decorated return view(*args, **kwargs) File "/app/api/controllers/console/app/wraps.py", line 49, in decorated_view return view_func(*args, **kwargs) File "/app/api/controllers/console/app/completion.py", line 149, in post raise InternalServerError() werkzeug.exceptions.InternalServerError: 500 Internal Server Error: The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application. ```
yindo added the 🐞 bug label 2026-02-21 18:15:03 -05:00
yindo closed this issue 2026-02-21 18:15:03 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Oct 24, 2024):

There is a similar issue that was discussed and resolved, which might be relevant to your problem. In the discussion titled "500 Internal Server Error when upload a file," it was suggested to remove local images and deploy them again with version 0.10.1 [1].

Regarding the error you're encountering, it seems to be related to the created_by_role attribute in the MessageFile class. The error message indicates that a string is being used where an enum value is expected. The CreatedByRole is an enum with possible values ACCOUNT and END_USER [2]. Ensure that when initializing the MessageFile, the created_by_role is set using one of these enum values, not a plain string. This should resolve the AttributeError you're facing.

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Oct 24, 2024): <!-- Answer --> There is a similar issue that was discussed and resolved, which might be relevant to your problem. In the discussion titled "[500 Internal Server Error when upload a file](https://github.com/langgenius/dify/discussions/9748#discussioncomment-11035116)," it was suggested to remove local images and deploy them again with version 0.10.1 <sup>[[1]](https://github.com/langgenius/dify/discussions/9748)</sup>. Regarding the error you're encountering, it seems to be related to the `created_by_role` attribute in the `MessageFile` class. The error message indicates that a string is being used where an enum value is expected. The `CreatedByRole` is an enum with possible values `ACCOUNT` and `END_USER` <sup>[[2]](https://github.com/langgenius/dify/blob/main/api/models/enums.py)</sup>. Ensure that when initializing the `MessageFile`, the `created_by_role` is set using one of these enum values, not a plain string. This should resolve the `AttributeError` you're facing. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@crazywoola commented on GitHub (Oct 24, 2024):

Duplicated https://github.com/langgenius/dify/discussions/9748

@crazywoola commented on GitHub (Oct 24, 2024): Duplicated https://github.com/langgenius/dify/discussions/9748
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#6300