dify icon indicating copy to clipboard operation
dify copied to clipboard

when user content include "CAST()","SUM()","ROUND()" and so on,it will throw exception ConnectionResetError

Open dospy5200 opened this issue 10 months ago • 3 comments

Self Checks

  • [x] 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

v1.1.3

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Image

logs

[on_llm_before_invoke]
Model: gemma3:27b-it-fp16
Parameters:
Stream: False
User: 150c0cb9-548d-47e2-9c16-3abc68ef7afe
Prompt messages:
role: system
content: ##角色:你是财务数据分析专家。分析MCP返回的查询结果,并撰写分析报告
##关键规则:
1.所有数据已符合用户问题中的条件(如产品类型、日期范围)
2.直接使用提供的数据分析,不要质疑数据是否符合条件
3.不需再次筛选或确认数据类别/时间范围
4.数据为[]或空时,回复”没有查询到相关数据”,不得编造数据
5.不要有任何提示性语言
##分析报告要求:
1.对需要统计的数据进行统计分析.
2.记住:所有数据都符合用户问题条件,直接分析提供的数据。
以下是表格字段详细解释:
LINE_NUM 序号
SOURCE_TYPE 公司类型
ITEM_NAME 管理口径
|PERIOD_NAME| 数据期间
CUR_M_AMOUNT 当月的总金额
|LAST_M_AMOUNT| 去年同月的总金额
CUR_Q_AMOUNT 当季的总金额
|LAST_Q_AMOUNT|去年同季的总金额
CUR_Y_AMOUNT 今年累计的总金额
|LAST_Y_AMOUNT | 去年累计的总金额
M_GROW_AMOUNT | 当月对比去年同月的变动金额
M_GROW_RATE 当月对比去年同月的变动率
|Q_GROW_AMOUNT |当季对比去年同月的变动金额
Q_GROW_RATE| 当季对比去年同季的变动率
Y_GROW_AMOUNT 今年累计对比去年累计的变动金额
|Y_GROW_RATE| 今年累计对比去年累计的变动率
你需要按时管理口径一条一条分析,如
报销、日常费用:Q2支付3.3亿、同比-0.17亿(-5%): (1)集团不含XR:Q2支付同比-0.1亿(-3%),主要是①项目合作费同比-0.2亿(项目回款进度影响);②房贷借款同比-0.12亿,借款人数下降40%且借款条件增加;③个人报销同比-0.1亿(人数同比-11%);④项目外包费同比+0.08亿(项目定制费同比+0.06亿、回款进度);⑤会务费同比+0.08亿(线下年会);⑥人力外包费同比+0.05亿(错季度结算影响350万、人数增加影响150万);⑦机房带宽同比+0.05亿(ZR转GF);
其他经营活动流入:24H1收到0.84亿、同比-0.23亿(-22%),主要是去年同期有人工智能系统安全测试与鲁棒增强软硬件一体化系统项目款代收款项0.12亿(同时代付也相应减少,即同步造成报销、日常费用支出下降),服务保证金同比减少0.04亿,博士后科研经费同比减少0.01亿,房贷还款同比减少0.01亿;
role: user
content: CASE
WHEN ISNULL(t1.金额, 0) - ISNULL(t2.金额, 0) > 0 THEN
'同比增长 ' + FORMAT(ROUND((CAST(ISNULL(t1.金额, 0) AS DECIMAL(18, 2)) - CAST(ISNULL(t2.金额, 0) AS DECIMAL(18, 2))) / NULLIF(CAST(ISNULL(t2.金额, 0) AS DECIMAL(18, 2)), 0) * 100, 2), 'N2') + '%'
[on_llm_invoke_error]
2025-04-08 09:19:59.176 ERROR [Thread-1215 (_generate_worker)] [logging_callback.py:170] - [models] Server Unavailable Error, ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
Traceback (most recent call last):
File "/app/api/core/model_runtime/model_providers/__base/large_language_model.py", line 143, in invoke
for chunk in result:
^^^^^^
File "/app/api/core/plugin/manager/model.py", line 189, in invoke_llm
yield from response
File "/app/api/core/plugin/manager/base.py", line 189, in _request_with_plugin_daemon_response_stream
self._handle_plugin_daemon_error(error.error_type, error.message)
File "/app/api/core/plugin/manager/base.py", line 217, in _handle_plugin_daemon_error
raise InvokeServerUnavailableError(description=args.get("description"))
core.model_runtime.errors.invoke.InvokeServerUnavailableError: [models] Server Unavailable Error, ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
2025-04-08 09:19:59.177 ERROR [Thread-1215 (_generate_worker)] [app_generator.py:257] - Error when generating
Traceback (most recent call last):
File "/app/api/core/app/apps/agent_chat/app_generator.py", line 240, in _generate_worker
runner.run(
File "/app/api/core/app/apps/agent_chat/app_runner.py", line 245, in run
self._handle_invoke_result(
File "/app/api/core/app/apps/base_app_runner.py", line 278, in _handle_invoke_result
self._handle_invoke_result_stream(invoke_result=invoke_result, queue_manager=queue_manager, agent=agent)
File "/app/api/core/app/apps/base_app_runner.py", line 313, in _handle_invoke_result_stream
for result in invoke_result:
^^^^^^^^^^^^^
File "/app/api/core/agent/fc_agent_runner.py", line 91, in run
chunks: Union[Generator[LLMResultChunk, None, None], LLMResult] = model_instance.invoke_llm(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/core/model_manager.py", line 165, in invoke_llm
self._round_robin_invoke(
File "/app/api/core/model_manager.py", line 370, in _round_robin_invoke
return function(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/core/model_runtime/model_providers/__base/large_language_model.py", line 180, in invoke
raise self._transform_invoke_error(e)
File "/app/api/core/model_runtime/model_providers/__base/large_language_model.py", line 143, in invoke
for chunk in result:
^^^^^^
File "/app/api/core/plugin/manager/model.py", line 189, in invoke_llm
yield from response
File "/app/api/core/plugin/manager/base.py", line 189, in _request_with_plugin_daemon_response_stream
self._handle_plugin_daemon_error(error.error_type, error.message)
File "/app/api/core/plugin/manager/base.py", line 217, in _handle_plugin_daemon_error
raise InvokeServerUnavailableError(description=args.get("description"))
core.model_runtime.errors.invoke.InvokeServerUnavailableError: [models] Server Unavailable Error, ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
2025-04-08 09:19:59.188 INFO [Thread-1214 (process_request_thread)] [_internal.py:97] - 192.168.104.64 - - [08/Apr/2025 09:19:59] "POST /console/api/apps/370e82ef-1d47-4611-8b02-79b71de8b3d4/chat-messages HTTP/1.1" 200 -
[on_llm_before_invoke]
Model: QwQ-32B
Parameters:
Stream: True
User: 150c0cb9-548d-47e2-9c16-3abc68ef7afe
Prompt messages:
role: system
content: Use the following context as your learned knowledge, inside <context></context> XML tags.
<context>
data-url="https://learnvideo.s.wcsapi.biz.matocloud.com/robot/console/88786ad01ffc4023841d7960543bd851/kb/image/7cc516e091894dc3a6274c701b1dbe90.gif"width="400"height="200"></b></p><p><b>方法二、单用户分析中查看;</b></p><p>在数据中心【内置数据中心/外置数据中心】-【用户行为分析】-【单用户分析】中根据自己的需求去设置参数然后点击统计查看即可</p>"
应用流量排名..............................................................................................................................60
5.4.3业务流量排名..............................................................................................................................60
5.4.4流量管理状态..............................................................................................................................61
5.4.5链路负载状态..............................................................................................................................61
流量时长分析..........................................................................................................................723
11.1.4终端接入分析..........................................................................................................................724
11.2业务分析.....................................................................................................................................725
11.3带宽分析.....................................................................................................................................727
11.3.1应用场景..................................................................................................................................727
11.3.2配置步骤..................................................................................................................................727
11.3.3数据分析..................................................................................................................................729
11.4未关机检测分析.........................................................................................................................729
11.4.1应用场景..................................................................................................................................729
11.4.2配置步骤..................................................................................................................................729
11.4.3数据分析..................................................................................................................................730
11.5办公上网态势分析.....................................................................................................................731
11.5.1应用场景..................................................................................................................................731
11.5.2配置步骤..................................................................................................................................731
11.5.2.1内容布局...............................................................................................................................733
11.5.2.2不良内容定义.......................................................................................................................736
11.5.2.3显示设置...............................................................................................................................736
11.5.3数据分析..................................................................................................................................738
12典型场景案例集............................................................................................................................739
12.1办公出口上网场景.....................................................................................................................739
12.1.1需求背景..................................................................................................................................739
12.1.2
旁路模式......................................................................................................................................35
2.2.4单臂模式......................................................................................................................................40
3机器人................................................................................................................................46
4首页....................................................................................................................................................47
4.1信息概览.........................................................................................................................................47
4.2流量分析.........................................................................................................................................48
4.3资产分析.........................................................................................................................................48
4.4行为风险分析.................................................................................................................................49
4.5系统状态.........................................................................................................................................51
5全网监控............................................................................................................................................52
5.1入网用户管理.................................................................................................................................52
5.1.1在线用户管理..............................................................................................................................52
5.1.2近七天入网失败用户..................................................................................................................54
5.2全网终端监控.................................................................................................................................55
5.2.1发现设置......................................................................................................................................55
5.2.2终端列表......................................................................................................................................56
5.2.3IP 管理.........................................................................................................................................58
5.3合规检查状态.................................................................................................................................59
5.4流量状态.........................................................................................................................................59
5.4.1用户流量排名..............................................................................................................................59
5.4.2应用流量排名..............................................................................................................................60
5.4.3业务流量排名..............................................................................................................................60
5.4.4
步骤2. 进入应用<设置>,根据实际需求设置未关机定义的耗电计算方法,当不需要设
置未关机定义的员工可添加到白名单
</context>
When answer to user:
- If you don't know, just say that you don't know.
- If you don't know when you are not sure, ask for clarification.
Avoid mentioning that you obtained the information from the context.
And answer according to the language of the user's question.
role: user
content: CASE
WHEN ISNULL(t1.金额, 0) - ISNULL(t2.金额, 0) > 0 THEN
'同比增长 ' + FORMAT(ROUND((CAST(ISNULL(t1.金额, 0) AS DECIMAL(18, 2)) - CAST(ISNULL(t2.金额, 0) AS DECIMAL(18, 2))) / NULLIF(CAST(ISNULL(t2.金额, 0) AS DECIMAL(18, 2)), 0) * 100, 2), 'N2') + '%'
[on_llm_new_chunk]2025-04-08 09:30:25.306 ERROR [Thread-1592 (_generate_worker)] [app_generator.py:243] - Error when generating
Traceback (most recent call last):
File "/app/api/core/app/apps/chat/app_generator.py", line 226, in _generate_worker
runner.run(
File "/app/api/core/app/apps/chat/app_runner.py", line 231, in run
self._handle_invoke_result(
File "/app/api/core/app/apps/base_app_runner.py", line 278, in _handle_invoke_result
self._handle_invoke_result_stream(invoke_result=invoke_result, queue_manager=queue_manager, agent=agent)
File "/app/api/core/app/apps/base_app_runner.py", line 313, in _handle_invoke_result_stream
for result in invoke_result:
^^^^^^^^^^^^^
File "/app/api/core/model_runtime/model_providers/__base/large_language_model.py", line 261, in _invoke_result_generator
raise self._transform_invoke_error(e)
File "/app/api/core/model_runtime/model_providers/__base/large_language_model.py", line 237, in _invoke_result_generator
for chunk in result:
^^^^^^
File "/app/api/core/plugin/manager/model.py", line 189, in invoke_llm
yield from response
File "/app/api/core/plugin/manager/base.py", line 189, in _request_with_plugin_daemon_response_stream
self._handle_plugin_daemon_error(error.error_type, error.message)
File "/app/api/core/plugin/manager/base.py", line 217, in _handle_plugin_daemon_error
raise InvokeServerUnavailableError(description=args.get("description"))
core.model_runtime.errors.invoke.InvokeServerUnavailableError: [models] Server Unavailable Error, ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
2025-04-08 09:30:25.319 INFO [Thread-1591 (process_request_thread)] [_internal.py:97] - 192.168.104.64 - - [08/Apr/2025 09:30:25] "POST /console/api/apps/009ef4af-7754-48aa-bfeb-714cfde8c0c6/chat-messages HTTP/1.1" 200 -

✔️ Expected Behavior

No response

❌ Actual Behavior

No response

dospy5200 avatar Apr 08 '25 09:04 dospy5200

你好,@dospy5200!我是一个可以帮助你解决bug、回答问题并成为贡献者的机器人。很高兴为你提供帮助,等待人类维护者的回复。如果有任何问题,请随时告诉我!

The ConnectionResetError you're encountering when using SQL-like functions such as CAST(), SUM(), and ROUND() in the Dify platform might be related to server connection issues. Specifically, this error can occur due to problems with the server being unavailable or the connection being reset by the peer. This is often indicated by the error message "Server Unavailable Error, ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))" in the logs.

To address this issue, you might want to check the server's availability and ensure that the network connection is stable. Additionally, reviewing the server logs for any specific errors or patterns that occur when these SQL-like functions are used could provide more insights into the root cause. If the server is behind a CDN like Cloudflare, there might be additional configurations needed to handle such requests properly.

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] avatar Apr 08 '25 09:04 dosubot[bot]

same

william4s avatar May 29 '25 08:05 william4s

same bug ⚠️

VastOcean-Yang avatar May 29 '25 08:05 VastOcean-Yang

some bug! I heard that it may be caused by enabling function calling?

HMT970958361 avatar Jul 03 '25 12:07 HMT970958361

I think it might related to the providers's security policies.

crazywoola avatar Jul 10 '25 06:07 crazywoola