mirror of
https://gitcode.com/ageerle/ruoyi-ai.git
synced 2026-09-13 00:14:59 +00:00
fix: 兼容 Atlas 预测结果查询 404,避免前端轮询刷屏
Atlas /model/prediction/{id} 对已过期或不存在的任务返回 404
(常见于更换 API Key 后残留的旧任务)。原实现直接抛异常,前端
轮询反复触发错误提示。改为 404 时返回 status=failed 的响应,
让上层走正常失败分支落库,前端识别后终止轮询。
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -36,6 +36,17 @@ public class AtlasPredictionService {
|
||||
try (Response response = okHttpClient.newCall(request).execute()) {
|
||||
ResponseBody body = response.body();
|
||||
String responseText = body == null ? "" : body.string();
|
||||
// 404: 预测任务已过期或不存在(常见于更换 API Key 后残留的旧任务),按失败处理,
|
||||
// 避免前端轮询反复触发异常提示。其余非 2xx 仍按异常抛出。
|
||||
if (response.code() == 404) {
|
||||
log.warn("Atlas Cloud 预测任务不存在或已过期: predictionId={}, category={}", predictionId, model.getCategory());
|
||||
return MediaGenerationResponse.builder()
|
||||
.type(mediaType(model.getCategory()))
|
||||
.mimeType("image".equals(model.getCategory()) ? "image/png" : "video/mp4")
|
||||
.status("failed")
|
||||
.rawResponse(responseText)
|
||||
.build();
|
||||
}
|
||||
if (!response.isSuccessful()) {
|
||||
throw new IllegalArgumentException("Atlas Cloud生成结果查询失败: " + response.code() + " - " + responseText);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user