KAG icon indicating copy to clipboard operation
KAG copied to clipboard

[Bug] [Module Name] Bug title 后端执行Example/TwoWikiTest项目的操作,将图谱同步到产品端,产品端无法做知识问答的推理,我在日志中发现了错误信息;但在后端可以执行qa.py

Open yzhbreeze opened this issue 10 months ago • 4 comments

Search before asking

  • [x] I had searched in the issues and found no similar issues.

Operating system information

Linux

What happened

2025-02-19 15:50:51,846 [] [] [http-nio-8887-exec-1] INFO c.a.o.a.h.s.f.AclFilter - aclFilter.gotoUrl:/#/login 2025-02-19 15:50:51,859 [] [] [http-nio-8887-exec-1] INFO c.a.o.c.r.s.i.TaskServiceImpl - start_run_nlQuery_task,task={"dsl":"Which Stanford University professor works on Alzheimer's?","id":16,"nl":"Which Stanford University professor works on Alzheimer's?","params":{},"projectId":3,"resultMessage":"[]","sessionId":6,"status":"INIT","userId":111111} 2025-02-19 15:50:51,860 [] [] [http-nio-8887-exec-1] INFO c.a.o.a.h.s.f.AclFilter - [POST:http://127.0.0.1:8887/v1/datas/asyncSubmit] cost:14 2025-02-19 15:50:51,875 [] [] [http-nio-8887-exec-7] INFO c.a.o.a.h.s.f.AclFilter - aclFilter.gotoUrl:/#/login 2025-02-19 15:50:51,877 [] [] [http-nio-8887-exec-7] INFO c.a.o.a.h.s.f.AclFilter - [GET:http://127.0.0.1:8887/v1/datas/query/16] cost:2 2025-02-19 15:50:52,086 [] [] [Thread-3] INFO c.a.o.c.r.s.i.TaskRunner - reasoner_task_done,id=16 2025-02-19 15:50:52,087 [] [] [Thread-3] INFO c.a.o.c.r.s.i.TaskCallBack - reasoner_task_id=16,update_status=null 2025-02-19 15:50:52,090 [] [] [Thread-3] ERROR c.a.o.c.r.s.i.TaskRunner - get task result error, org.springframework.jdbc.BadSqlGrammarException:

Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'where id = 16' at line 3

The error may exist in class path resource [mapper2/ReasonTaskDOMapper.xml]**

The error may involve com.antgroup.openspgapp.infra.dao.mapper.ReasonTaskDOMapper.updateByPrimaryKeySelective-Inline

The error occurred while setting parameters

SQL: update kg_reason_task where id = ?

Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'where id = 16' at line 3

; bad SQL grammar []

How to reproduce

Step 1:进入项目目录cd kag/examples/TwoWikiTest step2:修改配置文件 step3:knext project update --proj_path . step4:导入文档;获取预料;编辑schema;提交schema至服务端; step5:执行构建任务; step6:在产品端执行推理问答,发现一直在转圈,同时查看服务端日志,发现报错 但我我在产品端导入文档构建图谱,然后进行知识推理问答,可以正常运行

Are you willing to submit PR?

  • [x] Yes I am willing to submit a PR!

yzhbreeze avatar Feb 20 '25 05:02 yzhbreeze

遇到了同样的问题,请问解决了吗?是mybastic 映射文件没有更新吗?

Chelsea-Coder-Fan avatar Mar 07 '25 06:03 Chelsea-Coder-Fan

遇到了同样的问题,请问解决了吗?是mybastic 映射文件没有更新吗?

没有解决,放弃了,直接在后端执行qa了

yzhbreeze avatar Mar 07 '25 09:03 yzhbreeze

你好通过阅读源码,发现是由于 sql mapping中 set 部分 空导致执行了 update reason_task xxx(空对象) where id=xx,空对象是由于前置NlQueryTask任务分支中project manager info 获取config失败导致后续 task 没有 set 对应值。 为源码bug导致。

spg app源码反编译(此部分未开源): Image

Image

Image (如上红框 biz 配置 缺失了,图片为修复后的样子)

如下由于没有设置 biz 对应的 prompt,应该会抛出 NPE,导致task状态没有正确设置:

Image

解决:

  1. 规避:通过 biz 设置默认值,config 保存完整。 Image
  2. 源码彻底bug解决: 1)需要在开发者模式时,自动上传项目配置并且校验配置缺失时,设置默认值(在页面上,该选项是必选项,但是开发者模式时该值自动缺了,所以是 bug),防止 config 丢失或者不完整。 2)NPE 识别判断,并且在 TaskRunner 判断 Task Future 状态时,判断Done方法是有问题的(call() 抛Exception 也为Done)。

Image

@northmachine 可以再确认下

Chelsea-Coder-Fan avatar Mar 08 '25 13:03 Chelsea-Coder-Fan

你好通过阅读源码,发现是由于 sql mapping中 set 部分 空导致执行了 update reason_task xxx(空对象) where id=xx,空对象是由于前置NlQueryTask任务分支中project manager info 获取config失败导致后续 task 没有 set 对应值。 为源码bug导致。

spg app源码反编译(此部分未开源): Image

Image ![Image](https://github.com/user-attachments/assets/01fc05d3-4a14-4013-b7c7-7a2557fa4c77) (如上红框 biz 配置 缺失了,图片为修复后的样子)

如下由于没有设置 biz 对应的 prompt,应该会抛出 NPE,导致task状态没有正确设置:

Image

解决:

  1. 规避:通过 biz 设置默认值,config 保存完整。

Image 2. 源码彻底bug解决: 1)需要在开发者模式时,自动上传项目配置并且校验配置缺失时,设置默认值(在页面上,该选项是必选项,但是开发者模式时该值自动缺了,所以是 bug),防止 config 丢失或者不完整。 2)NPE 识别判断,并且在 TaskRunner 判断 Task Future 状态时,判断Done方法是有问题的(call() 抛Exception 也为Done)。 Image

@northmachine 可以再确认下

大佬真厉害,我都没找到spg app源码在哪里,希望官方团队看到了修改下吧

yzhbreeze avatar Mar 11 '25 01:03 yzhbreeze

This bug has been fixed in KAG V0.8, you can try out the latest version.

caszkgui avatar Aug 16 '25 08:08 caszkgui