API Call error 500 #13266

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

Originally created by @tientaisv on GitHub (Apr 23, 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.3.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

2025-04-23 13:49:31.529 ERROR [Dummy-6] [app.py:875] - Exception on /v1/chat-messages [POST]
2025-04-23 13:49:31
 Traceback (most recent call last):
2025-04-23 13:49:31
   File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 917, in full_dispatch_request
2025-04-23 13:49:31
     rv = self.dispatch_request()
2025-04-23 13:49:31
          ^^^^^^^^^^^^^^^^^^^^^^^
2025-04-23 13:49:31
   File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 902, in dispatch_request
2025-04-23 13:49:31
     return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
2025-04-23 13:49:31
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-04-23 13:49:31
   File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 489, in wrapper
2025-04-23 13:49:31
     resp = resource(*args, **kwargs)
2025-04-23 13:49:31
            ^^^^^^^^^^^^^^^^^^^^^^^^^
2025-04-23 13:49:31
   File "/app/api/.venv/lib/python3.12/site-packages/flask/views.py", line 110, in view
2025-04-23 13:49:31
     return current_app.ensure_sync(self.dispatch_request)(**kwargs)  # type: ignore[no-any-return]
2025-04-23 13:49:31
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-04-23 13:49:31
   File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 604, in dispatch_request
2025-04-23 13:49:31
     resp = meth(*args, **kwargs)
2025-04-23 13:49:31
            ^^^^^^^^^^^^^^^^^^^^^
2025-04-23 13:49:31
   File "/app/api/controllers/service_api/wraps.py", line 68, in decorated_view
2025-04-23 13:49:31
     .one_or_none()
2025-04-23 13:49:31
      ^^^^^^^^^^^^^
2025-04-23 13:49:31
   File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/orm/query.py", line 2754, in one_or_none
2025-04-23 13:49:31
     return self._iter().one_or_none()  # type: ignore
2025-04-23 13:49:31
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-04-23 13:49:31
   File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/result.py", line 1441, in one_or_none
2025-04-23 13:49:31
     return self._only_one_row(
2025-04-23 13:49:31
            ^^^^^^^^^^^^^^^^^^^
2025-04-23 13:49:31
   File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/result.py", line 805, in _only_one_row
2025-04-23 13:49:31
     raise exc.MultipleResultsFound(
2025-04-23 13:49:31
 sqlalchemy.exc.MultipleResultsFound: Multiple rows were found when one or none was required

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @tientaisv on GitHub (Apr 23, 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.3.0 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce ``` 2025-04-23 13:49:31.529 ERROR [Dummy-6] [app.py:875] - Exception on /v1/chat-messages [POST] 2025-04-23 13:49:31 Traceback (most recent call last): 2025-04-23 13:49:31 File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 917, in full_dispatch_request 2025-04-23 13:49:31 rv = self.dispatch_request() 2025-04-23 13:49:31 ^^^^^^^^^^^^^^^^^^^^^^^ 2025-04-23 13:49:31 File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 902, in dispatch_request 2025-04-23 13:49:31 return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return] 2025-04-23 13:49:31 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-04-23 13:49:31 File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 489, in wrapper 2025-04-23 13:49:31 resp = resource(*args, **kwargs) 2025-04-23 13:49:31 ^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-04-23 13:49:31 File "/app/api/.venv/lib/python3.12/site-packages/flask/views.py", line 110, in view 2025-04-23 13:49:31 return current_app.ensure_sync(self.dispatch_request)(**kwargs) # type: ignore[no-any-return] 2025-04-23 13:49:31 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-04-23 13:49:31 File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 604, in dispatch_request 2025-04-23 13:49:31 resp = meth(*args, **kwargs) 2025-04-23 13:49:31 ^^^^^^^^^^^^^^^^^^^^^ 2025-04-23 13:49:31 File "/app/api/controllers/service_api/wraps.py", line 68, in decorated_view 2025-04-23 13:49:31 .one_or_none() 2025-04-23 13:49:31 ^^^^^^^^^^^^^ 2025-04-23 13:49:31 File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/orm/query.py", line 2754, in one_or_none 2025-04-23 13:49:31 return self._iter().one_or_none() # type: ignore 2025-04-23 13:49:31 ^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-04-23 13:49:31 File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/result.py", line 1441, in one_or_none 2025-04-23 13:49:31 return self._only_one_row( 2025-04-23 13:49:31 ^^^^^^^^^^^^^^^^^^^ 2025-04-23 13:49:31 File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/result.py", line 805, in _only_one_row 2025-04-23 13:49:31 raise exc.MultipleResultsFound( 2025-04-23 13:49:31 sqlalchemy.exc.MultipleResultsFound: Multiple rows were found when one or none was required ``` ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug label 2026-02-21 19:11:20 -05:00
yindo closed this issue 2026-02-21 19:11:20 -05:00
Author
Owner

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

Hello @tientaisv! I'm Dosu, your friendly bot here to help you solve bugs, answer questions, and assist with contributions while you wait for a human maintainer. Let's tackle this issue together!

I found a similar unsolved discussion regarding a "Response[500] Internal Server Error" [1]. This might be related to the issue you're experiencing.

The error you're encountering, MultipleResultsFound, typically occurs when a query that is expected to return one or no results actually returns multiple rows. In the context of the decorated_view method, this exception is raised when the query using one_or_none() finds more than one result. This suggests that the query conditions might not be specific enough, or the data in the database might have duplicates or unexpected entries.

To resolve this issue, you can:

  1. Check the Query Conditions: Ensure that the query conditions in the decorated_view method are correctly set to uniquely identify the expected result. You might need to add more specific filters to the query.

  2. Inspect the Database: Look into the database to verify that the data does not contain duplicates or entries that could lead to multiple results for the query.

  3. Modify the Code: If the query is supposed to handle multiple results, consider using a method that can process multiple rows, such as all() or first(), depending on the logic you need.

If you need further assistance with the specific query or code adjustments, feel free to provide more details or ask additional questions.

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 23, 2025): <!-- Greeting --> Hello @tientaisv! I'm [Dosu](https://dosu.dev), your friendly bot here to help you solve bugs, answer questions, and assist with contributions while you wait for a human maintainer. Let's tackle this issue together! <!-- Answer --> I found a similar unsolved discussion regarding a "Response[500] Internal Server Error" <sup>[[1]](https://github.com/langgenius/dify/discussions/16104)</sup>. This might be related to the issue you're experiencing. The error you're encountering, `MultipleResultsFound`, typically occurs when a query that is expected to return one or no results actually returns multiple rows. In the context of the `decorated_view` method, this exception is raised when the query using `one_or_none()` finds more than one result. This suggests that the query conditions might not be specific enough, or the data in the database might have duplicates or unexpected entries. To resolve this issue, you can: 1. **Check the Query Conditions:** Ensure that the query conditions in the `decorated_view` method are correctly set to uniquely identify the expected result. You might need to add more specific filters to the query. 2. **Inspect the Database:** Look into the database to verify that the data does not contain duplicates or entries that could lead to multiple results for the query. 3. **Modify the Code:** If the query is supposed to handle multiple results, consider using a method that can process multiple rows, such as `all()` or `first()`, depending on the logic you need. If you need further assistance with the specific query or code adjustments, feel free to provide more details or ask additional questions. <!-- 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/03fea552-1279-4937-81c0-06fcc7f04a7f?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/03fea552-1279-4937-81c0-06fcc7f04a7f?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/03fea552-1279-4937-81c0-06fcc7f04a7f?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/03fea552-1279-4937-81c0-06fcc7f04a7f?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/03fea552-1279-4937-81c0-06fcc7f04a7f?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/03fea552-1279-4937-81c0-06fcc7f04a7f?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/03fea552-1279-4937-81c0-06fcc7f04a7f?feedback_type=other)</sup>
Author
Owner

@tientaisv commented on GitHub (Apr 23, 2025):

@dosu I'm using a Docker environment, so I can't edit the code directly. At the same time, when I downgrade to a lower version than 0.14, it works fine without this error. Please help me update the Docker image that has fixed this issue, the error with the specific API link in your application.

@tientaisv commented on GitHub (Apr 23, 2025): @dosu I'm using a Docker environment, so I can't edit the code directly. At the same time, when I downgrade to a lower version than 0.14, it works fine without this error. Please help me update the Docker image that has fixed this issue, the error with the specific API link in your application.
Author
Owner

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

To update the Docker image and resolve the MultipleResultsFound error by downgrading to a version lower than 0.14, follow these steps:

  1. Open the docker/docker-compose.yaml file in your project.
  2. Change the image version to a version lower than 0.14. For example, update the line from langgenius/dify-web:0.15.3 to langgenius/dify-web:0.13.x.
  3. Run the following commands in your terminal to apply the changes:
    docker compose down
    docker compose pull
    docker compose up -d
    

This will pull the specified version of the Docker image and restart your application with the updated image, which should resolve the error [1].

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 23, 2025): <!-- Answer --> To update the Docker image and resolve the `MultipleResultsFound` error by downgrading to a version lower than 0.14, follow these steps: 1. Open the `docker/docker-compose.yaml` file in your project. 2. Change the image version to a version lower than 0.14. For example, update the line from `langgenius/dify-web:0.15.3` to `langgenius/dify-web:0.13.x`. 3. Run the following commands in your terminal to apply the changes: ```bash docker compose down docker compose pull docker compose up -d ``` This will pull the specified version of the Docker image and restart your application with the updated image, which should resolve the error <sup>[[1]](https://github.com/langgenius/dify/issues/14165)</sup>. <!-- 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/e0cee510-3ee9-4a4d-b633-3fbacb32b200?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/e0cee510-3ee9-4a4d-b633-3fbacb32b200?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/e0cee510-3ee9-4a4d-b633-3fbacb32b200?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/e0cee510-3ee9-4a4d-b633-3fbacb32b200?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/e0cee510-3ee9-4a4d-b633-3fbacb32b200?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/e0cee510-3ee9-4a4d-b633-3fbacb32b200?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/e0cee510-3ee9-4a4d-b633-3fbacb32b200?feedback_type=other)</sup>
Author
Owner

@tientaisv commented on GitHub (Apr 23, 2025):

I'm using version 1.3.0.

@tientaisv commented on GitHub (Apr 23, 2025): I'm using version 1.3.0.
Author
Owner

@stephonye commented on GitHub (Apr 24, 2025):

up

@stephonye commented on GitHub (Apr 24, 2025): up
Author
Owner

@hieheihei commented on GitHub (Apr 30, 2025):

It seems that there is dirty data in your DB,the tenant-related tables: tenants & tenant_account_joins.

Self Checks

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

Dify version

1.3.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

2025-04-23 13:49:31.529 ERROR [Dummy-6] [app.py:875] - Exception on /v1/chat-messages [POST]
2025-04-23 13:49:31
 Traceback (most recent call last):
2025-04-23 13:49:31
   File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 917, in full_dispatch_request
2025-04-23 13:49:31
     rv = self.dispatch_request()
2025-04-23 13:49:31
          ^^^^^^^^^^^^^^^^^^^^^^^
2025-04-23 13:49:31
   File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 902, in dispatch_request
2025-04-23 13:49:31
     return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
2025-04-23 13:49:31
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-04-23 13:49:31
   File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 489, in wrapper
2025-04-23 13:49:31
     resp = resource(*args, **kwargs)
2025-04-23 13:49:31
            ^^^^^^^^^^^^^^^^^^^^^^^^^
2025-04-23 13:49:31
   File "/app/api/.venv/lib/python3.12/site-packages/flask/views.py", line 110, in view
2025-04-23 13:49:31
     return current_app.ensure_sync(self.dispatch_request)(**kwargs)  # type: ignore[no-any-return]
2025-04-23 13:49:31
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-04-23 13:49:31
   File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 604, in dispatch_request
2025-04-23 13:49:31
     resp = meth(*args, **kwargs)
2025-04-23 13:49:31
            ^^^^^^^^^^^^^^^^^^^^^
2025-04-23 13:49:31
   File "/app/api/controllers/service_api/wraps.py", line 68, in decorated_view
2025-04-23 13:49:31
     .one_or_none()
2025-04-23 13:49:31
      ^^^^^^^^^^^^^
2025-04-23 13:49:31
   File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/orm/query.py", line 2754, in one_or_none
2025-04-23 13:49:31
     return self._iter().one_or_none()  # type: ignore
2025-04-23 13:49:31
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-04-23 13:49:31
   File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/result.py", line 1441, in one_or_none
2025-04-23 13:49:31
     return self._only_one_row(
2025-04-23 13:49:31
            ^^^^^^^^^^^^^^^^^^^
2025-04-23 13:49:31
   File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/result.py", line 805, in _only_one_row
2025-04-23 13:49:31
     raise exc.MultipleResultsFound(
2025-04-23 13:49:31
 sqlalchemy.exc.MultipleResultsFound: Multiple rows were found when one or none was required

✔️ Expected Behavior

No response

Actual Behavior

No response

@hieheihei commented on GitHub (Apr 30, 2025): It seems that there is dirty data in your DB,the tenant-related tables: tenants & tenant_account_joins. > ### 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.3.0 > > ### Cloud or Self Hosted > Self Hosted (Docker) > > ### Steps to reproduce > ``` > 2025-04-23 13:49:31.529 ERROR [Dummy-6] [app.py:875] - Exception on /v1/chat-messages [POST] > 2025-04-23 13:49:31 > Traceback (most recent call last): > 2025-04-23 13:49:31 > File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 917, in full_dispatch_request > 2025-04-23 13:49:31 > rv = self.dispatch_request() > 2025-04-23 13:49:31 > ^^^^^^^^^^^^^^^^^^^^^^^ > 2025-04-23 13:49:31 > File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 902, in dispatch_request > 2025-04-23 13:49:31 > return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return] > 2025-04-23 13:49:31 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > 2025-04-23 13:49:31 > File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 489, in wrapper > 2025-04-23 13:49:31 > resp = resource(*args, **kwargs) > 2025-04-23 13:49:31 > ^^^^^^^^^^^^^^^^^^^^^^^^^ > 2025-04-23 13:49:31 > File "/app/api/.venv/lib/python3.12/site-packages/flask/views.py", line 110, in view > 2025-04-23 13:49:31 > return current_app.ensure_sync(self.dispatch_request)(**kwargs) # type: ignore[no-any-return] > 2025-04-23 13:49:31 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > 2025-04-23 13:49:31 > File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 604, in dispatch_request > 2025-04-23 13:49:31 > resp = meth(*args, **kwargs) > 2025-04-23 13:49:31 > ^^^^^^^^^^^^^^^^^^^^^ > 2025-04-23 13:49:31 > File "/app/api/controllers/service_api/wraps.py", line 68, in decorated_view > 2025-04-23 13:49:31 > .one_or_none() > 2025-04-23 13:49:31 > ^^^^^^^^^^^^^ > 2025-04-23 13:49:31 > File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/orm/query.py", line 2754, in one_or_none > 2025-04-23 13:49:31 > return self._iter().one_or_none() # type: ignore > 2025-04-23 13:49:31 > ^^^^^^^^^^^^^^^^^^^^^^^^^^ > 2025-04-23 13:49:31 > File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/result.py", line 1441, in one_or_none > 2025-04-23 13:49:31 > return self._only_one_row( > 2025-04-23 13:49:31 > ^^^^^^^^^^^^^^^^^^^ > 2025-04-23 13:49:31 > File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/result.py", line 805, in _only_one_row > 2025-04-23 13:49:31 > raise exc.MultipleResultsFound( > 2025-04-23 13:49:31 > sqlalchemy.exc.MultipleResultsFound: Multiple rows were found when one or none was required > ``` > > ### ✔️ Expected Behavior > _No response_ > > ### ❌ Actual Behavior > _No response_
Author
Owner

@geosmart commented on GitHub (May 16, 2025):

the same error in 1.3.1, when I call the api

^[[A2025-05-16 05:57:38.166 ERROR [Dummy-60] [app.py:875] - Exception on /v1/chat-messages [POST]
Traceback (most recent call last):
  File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 917, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 902, 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.12/site-packages/flask_restful/__init__.py", line 489, in wrapper
    resp = resource(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/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.12/site-packages/flask_restful/__init__.py", line 604, in dispatch_request
    resp = meth(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/app/api/controllers/service_api/wraps.py", line 68, in decorated_view
    .one_or_none()
     ^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/orm/query.py", line 2754, in one_or_none
    return self._iter().one_or_none()  # type: ignore
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/result.py", line 1441, in one_or_none
    return self._only_one_row(
           ^^^^^^^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/result.py", line 805, in _only_one_row
    raise exc.MultipleResultsFound(
sqlalchemy.exc.MultipleResultsFound: Multiple rows were found when one or none was required


@geosmart commented on GitHub (May 16, 2025): the same error in 1.3.1, when I call the api ```python ^[[A2025-05-16 05:57:38.166 ERROR [Dummy-60] [app.py:875] - Exception on /v1/chat-messages [POST] Traceback (most recent call last): File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 917, in full_dispatch_request rv = self.dispatch_request() ^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 902, 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.12/site-packages/flask_restful/__init__.py", line 489, in wrapper resp = resource(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/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.12/site-packages/flask_restful/__init__.py", line 604, in dispatch_request resp = meth(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/app/api/controllers/service_api/wraps.py", line 68, in decorated_view .one_or_none() ^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/orm/query.py", line 2754, in one_or_none return self._iter().one_or_none() # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/result.py", line 1441, in one_or_none return self._only_one_row( ^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/result.py", line 805, in _only_one_row raise exc.MultipleResultsFound( sqlalchemy.exc.MultipleResultsFound: Multiple rows were found when one or none was required ```
Author
Owner

@geosmart commented on GitHub (May 16, 2025):

File "/app/api/controllers/service_api/wraps.py", line 68, in decorated_view


            tenant_account_join = (
                db.session.query(Tenant, TenantAccountJoin)
                .filter(Tenant.id == api_token.tenant_id)
                .filter(TenantAccountJoin.tenant_id == Tenant.id)
                .filter(TenantAccountJoin.role.in_(["owner"]))
                .filter(Tenant.status == TenantStatus.NORMAL)
                .one_or_none()
            )  # TODO: only owner information is required, so only one is returned.

limit only one owner make this error!

I have multiple owner user, so just replace .one_or_none() to .first() save me

sed -i 's/\.one_or_none()/\.first()/g' /app/api/controllers/service_api/wraps.py
@geosmart commented on GitHub (May 16, 2025): File "/app/api/controllers/service_api/wraps.py", line 68, in decorated_view ```python tenant_account_join = ( db.session.query(Tenant, TenantAccountJoin) .filter(Tenant.id == api_token.tenant_id) .filter(TenantAccountJoin.tenant_id == Tenant.id) .filter(TenantAccountJoin.role.in_(["owner"])) .filter(Tenant.status == TenantStatus.NORMAL) .one_or_none() ) # TODO: only owner information is required, so only one is returned. ``` limit only one `owner` make this error! I have multiple owner user, so just replace `.one_or_none()` to `.first()` save me ```bash sed -i 's/\.one_or_none()/\.first()/g' /app/api/controllers/service_api/wraps.py ```
Author
Owner

@lambdaq commented on GitHub (Jun 20, 2025):

Let just change .one_or_none() to first() ?

@lambdaq commented on GitHub (Jun 20, 2025): Let just change `.one_or_none()` to `first()` ?
Author
Owner

@laipz8200 commented on GitHub (Jun 20, 2025):

Hi @geosmart,

According to our design, each tenant is assigned only one owner. Could you please explain how multiple owners were assigned?

@laipz8200 commented on GitHub (Jun 20, 2025): Hi @geosmart, According to our design, each tenant is assigned only one owner. Could you please explain how multiple owners were assigned?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#13266