Chat API error- '<' not supported between instances of 'NoneType' and 'float' #7658

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

Originally created by @OrWestSide on GitHub (Jan 10, 2025).

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.15.0

Cloud or Self Hosted

Cloud

Steps to reproduce

We are facing issues with the /chat-messages endpoint. In some cases, we get a 400 error and the body we get back is the following:

{
    "code": "invalid_param", 
    "message": "Run failed: Traceback (most recent call last):\\n  File \\"/var/sandbox/sandbox- 
                        python/tmp/4691b298_5083_4d50_8ace_2aac35c12581.py\\", line 48, in <module>\\n  File \\"<string>\\", line 38, in 
                        <module>\\n  File \\"<string>\\", line 18, in main\\nTypeError: \'<\' not supported between instances of \'NoneType\' 
                        and \'float\'\\nerror: exit status 255\\n", 
    "status": 400
}

This is the request body we are sending:

{
    "query": "Phone number", 
    "inputs": {....}, 
    "response_mode": "blocking", 
    "user": "xxx",
    "conversation_id": "yyy"
}

✔️ Expected Behavior

Requests to /chat-messages should be successful

Actual Behavior

Requests to /chat-messages are failing

Originally created by @OrWestSide on GitHub (Jan 10, 2025). ### 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.15.0 ### Cloud or Self Hosted Cloud ### Steps to reproduce We are facing issues with the `/chat-messages` endpoint. In some cases, we get a 400 error and the body we get back is the following: ``` { "code": "invalid_param", "message": "Run failed: Traceback (most recent call last):\\n File \\"/var/sandbox/sandbox- python/tmp/4691b298_5083_4d50_8ace_2aac35c12581.py\\", line 48, in <module>\\n File \\"<string>\\", line 38, in <module>\\n File \\"<string>\\", line 18, in main\\nTypeError: \'<\' not supported between instances of \'NoneType\' and \'float\'\\nerror: exit status 255\\n", "status": 400 } ``` This is the request body we are sending: ``` { "query": "Phone number", "inputs": {....}, "response_mode": "blocking", "user": "xxx", "conversation_id": "yyy" } ``` ### ✔️ Expected Behavior Requests to `/chat-messages` should be successful ### ❌ Actual Behavior Requests to `/chat-messages` are failing
yindo added the 🐞 bug label 2026-02-21 18:21:41 -05:00
yindo closed this issue 2026-02-21 18:21:41 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jan 10, 2025):

The error you're encountering, '<' not supported between instances of 'NoneType' and 'float', suggests that there is a comparison operation in the /chat-messages endpoint where a NoneType value is being compared to a float. This typically happens when a variable expected to have a numeric value is None.

To address this issue, you should:

  1. Check the Inputs: Ensure that all inputs being sent in the request body are correctly initialized and not None. This includes any values that might be used in calculations or comparisons.

  2. Review the Code: Look for any part of the code where a comparison is made between variables that could potentially be None. Adding checks to ensure that variables are not None before performing comparisons can prevent this error.

  3. Validation: Implement validation steps to ensure that all required fields are populated with valid data types before processing the request. This can help catch issues early and provide more informative error messages.

If the error persists, you may need to review the specific logic in the codebase where the comparison is happening to ensure that all variables are properly initialized and handled.

To continue talking to Dosu, mention @dosu.


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

@dosubot[bot] commented on GitHub (Jan 10, 2025): <!-- Answer --> The error you're encountering, `'<' not supported between instances of 'NoneType' and 'float'`, suggests that there is a comparison operation in the `/chat-messages` endpoint where a `NoneType` value is being compared to a `float`. This typically happens when a variable expected to have a numeric value is `None`. To address this issue, you should: 1. **Check the Inputs**: Ensure that all inputs being sent in the request body are correctly initialized and not `None`. This includes any values that might be used in calculations or comparisons. 2. **Review the Code**: Look for any part of the code where a comparison is made between variables that could potentially be `None`. Adding checks to ensure that variables are not `None` before performing comparisons can prevent this error. 3. **Validation**: Implement validation steps to ensure that all required fields are populated with valid data types before processing the request. This can help catch issues early and provide more informative error messages. If the error persists, you may need to review the specific logic in the codebase where the comparison is happening to ensure that all variables are properly initialized and handled. <!-- 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/7a19bbf2-5053-49ad-8061-c3c80b97b88e?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/7a19bbf2-5053-49ad-8061-c3c80b97b88e?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/7a19bbf2-5053-49ad-8061-c3c80b97b88e?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/7a19bbf2-5053-49ad-8061-c3c80b97b88e?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/7a19bbf2-5053-49ad-8061-c3c80b97b88e?feedback_type=hallucination) | [Other](https://app.dosu.dev/response-feedback/7a19bbf2-5053-49ad-8061-c3c80b97b88e?feedback_type=other)</sup>
Author
Owner

@crazywoola commented on GitHub (Jan 12, 2025):

400 error is raised by the code or http inside the workflow. Please check that as well.

@crazywoola commented on GitHub (Jan 12, 2025): 400 error is raised by the code or http inside the workflow. Please check that as well.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#7658