fix(api): report checkpoint deletion failures and classify SSE errors
Delete checkpoints before removing business fields. Suppress only an explicit CheckpointNotFoundError; propagate storage failures and cancellation so the endpoint cannot report false success. Prefer async checkpoint deletion and fail clearly when cleanup is unsupported. Classify SSE error events as 401 for authentication, 429 for rate limits, and 500 for other failures, using the same fixed messages as non-stream responses. Errors terminate the stream without a success done event or provider exception text in the response. Validation: 286 offline tests passed (19 added), including failed-delete HTTP retry with preserved business/checkpoint state, explicit missing threads, cancellation, missing cleanup capability, and HTTP SSE errors before and after text output.
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
| `set_info` 字段值 | 任意字符串原样存 | 按注册表类型解析(bool/int 严格),无法解析拒绝 | 保留 空/False/0/未知 区分,杜绝 `bool("0")` 陷阱 |
|
||||
| 图表单键与业务键 | FastGPT state 为裸 dict,无映射概念 | 建立双向映射(作业 6):表单六键(`has_injury` 等)<-> acd 业务键(`ywrysw` 等);`bjrjs`/`ywmtc` 无表单来源,仅 `set_info` 可写 | 图的表单语义与 get_info 业务分组需要同一份事实 |
|
||||
| LLM 调用 | set/get 走辅助对话 + 事后删记录 | **零 LLM 调用**(测试 spy 保证) | 成本与延迟;删除 race 消失 |
|
||||
| 重复 `delete_session` | FastGPT SDK 行为未固定 | **幂等成功**(业务状态删除天然幂等;checkpoint 清理重复触发但缺失静默容忍) | 行为固定为测试 |
|
||||
| 重复 `delete_session` | FastGPT SDK 行为未固定 | **幂等成功**(checkpoint 正常返回或适配器明确报告不存在才可继续;存储故障返回业务码 500) | 不再将清理失败当成删除成功 |
|
||||
|
||||
## 图表单键 <-> 业务键映射(作业 6 建立)
|
||||
|
||||
@@ -99,6 +99,16 @@
|
||||
取消流时先关闭内部生成器、取消图任务,再释放会话锁。
|
||||
- needFormUpdate 只决定对外是否返回差量。图提交时通过内部回调同步
|
||||
repository,关闭差量显示或消费者在提交后断开不会丢失业务字段。
|
||||
- 删除在同会话锁内先清理 checkpoint,再删除业务字段。只有存储正常返回,
|
||||
或适配器明确抛出 CheckpointNotFoundError 时才视为 checkpoint 清理成功;
|
||||
连接、超时、一般 RuntimeError/KeyError 等故障必须上报,业务字段保留供重试。
|
||||
缺少 checkpointer 或不支持删除操作也返回失败。优先使用 adelete_thread,
|
||||
仅在没有异步接口时兼容同步 delete_thread。若业务存储删除本身失败,
|
||||
同样返回失败;此顺序不构成跨存储事务,可能需要再次重试完成清理。
|
||||
- SSE 错误按 error 事件的 code 区分:鉴权 401、限流 429、其余 500,
|
||||
使用与非流式相同的固定文案,不回传底层异常原文。首包前和输出途中
|
||||
都使用同一分类;错误是终止事件,随后不会发送 done。已经建立的
|
||||
SSE HTTP 响应保持 200,调用方检查事件内的业务码。
|
||||
- SDK 自动重试关闭,由应用层统一控制;默认首次尝试加 3 次重试,
|
||||
每次尝试总超时 60 秒,退避 1、2、4 秒。单次 LLM 调用理论预算
|
||||
4×60+1+2+4=247 秒(另有响应关闭的清理时间)。FastGPT SDK 的
|
||||
@@ -114,4 +124,7 @@
|
||||
- `test/services/test_app_service.py`:四接口组合(set→get→chat 注入→
|
||||
差量写回→分组读→删除→无泄漏),set/get/delete 零模型调用 spy,
|
||||
重复删除幂等。
|
||||
- `test/api/test_assignment6_endpoints.py`:HTTP 层验收演示链路。
|
||||
- `test/api/test_assignment6_endpoints.py`:HTTP 层验收演示、删除失败保留数据及重试成功链路。
|
||||
- `test/services/test_delete_failure_semantics.py`:存储故障、明确不存在、取消、清理能力缺失与重试。
|
||||
- `test/api/test_stream_error_codes.py`:实际 LangGraphBackend 过 HTTP 协议层,
|
||||
验证首包前/输出途中 401、429、500 分类、文案与非流式一致、错误后无 done。
|
||||
|
||||
Reference in New Issue
Block a user