From 96a1b741df6b995c9d3c0c309d88441121363756 Mon Sep 17 00:00:00 2001 From: "ageerle@163.com" Date: Wed, 15 Jul 2026 11:17:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=85=BC=E5=AE=B9=20Atlas=20=E9=A2=84?= =?UTF-8?q?=E6=B5=8B=E7=BB=93=E6=9E=9C=E6=9F=A5=E8=AF=A2=20404=EF=BC=8C?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E5=89=8D=E7=AB=AF=E8=BD=AE=E8=AF=A2=E5=88=B7?= =?UTF-8?q?=E5=B1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Atlas /model/prediction/{id} 对已过期或不存在的任务返回 404 (常见于更换 API Key 后残留的旧任务)。原实现直接抛异常,前端 轮询反复触发错误提示。改为 404 时返回 status=failed 的响应, 让上层走正常失败分支落库,前端识别后终止轮询。 Co-Authored-By: Claude --- .../ruoyi/service/media/AtlasPredictionService.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/service/media/AtlasPredictionService.java b/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/service/media/AtlasPredictionService.java index bdf4f616..3c79205d 100644 --- a/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/service/media/AtlasPredictionService.java +++ b/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/service/media/AtlasPredictionService.java @@ -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); }