兼容新的mongo方法格式,并且修复client的apitoken覆盖问题

This commit is contained in:
Cold
2026-01-12 17:36:14 +08:00
committed by 张斌
parent 65dc3d525d
commit bf8b220a99
4 changed files with 94 additions and 15 deletions

View File

@@ -90,6 +90,11 @@ func (c *Client) CreateSession(ctx context.Context, chatId string, req *CreateSe
if res.Code != 0 {
return nil, gerror.Newf("create session failed: %s", res.Msg)
}
// 检查响应数据是否为空防止RAGFlow API返回 {"code":0, "data":null}
// 如果不检查直接返回,调用方会收到 (nil, nil),导致空指针异常
if res.Data == nil {
return nil, gerror.Newf("create session returned null data: %s", res.Msg)
}
return res.Data, nil
}