Skip to content

Conversation

wuzkcool
Copy link

@wuzkcool wuzkcool commented Sep 22, 2025

Describe what this PR does / why we need it

使用graph时出现了NPE。 错误详情: java.lang.NullPointerException: Cannot invoke "org.springframework.ai.chat.model.Generation.getOutput()" because the return value of "org.springframework.ai.chat.model.ChatResponse.getResult()" is null
image

已经有多个提交试图修复这个问题,他们添加了非空判断,但是没有完全覆盖所有的逻辑分支。比如:fix: result empty (#2464)

Does this pull request fix one issue?

Describe how you did it

在org.springframework.ai.chat.model.ChatResponse的方法定义,getResult()方法是会存在返回为null的场景。在spring ai alibaba中应该正确的处理返回值为null的场景
```
	public Generation getResult() {
	if (CollectionUtils.isEmpty(this.generations)) {
		return null;
	}
	return this.generations.get(0);
}
```

Describe how to verify it

使用graph时,开开启流式响应,使用qwen-max 模型当前ChatResponse.getResult()=null的某个chunk 时会出现npe

Special notes for reviews

@github-actions github-actions bot added the area/graph SAA Grpah module label Sep 22, 2025
@CLAassistant
Copy link

CLAassistant commented Sep 22, 2025

CLA assistant check
All committers have signed the CLA.

@wuzkcool wuzkcool changed the title feat(graph): filter ChatResponse.getResult() is null event fix(graph): filter ChatResponse.getResult() is null event Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/graph SAA Grpah module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants