fix(文案出口): 用户可见提示语一律走 UserMessages 把关,并补结果作业租约围栏

两件事同源:2026-10-09 任务 30456 的卡片上同时出现中文进度和一句英文异常原文。

围栏:派发链在执行前重读 job 行,让 activateRunningClaim 的 CAS 恒真,撞锁方
deferRunning 把在跑的行翻回 PENDING,markSuccess 静默写 0 行——成功被判成失败。
claim 快照现在贯穿到 runClaimed 不再回读,markSuccess 返回布尔并补 stage=SUCCESS_LOST
日志,让这次丢失可观测。

文案:普查数出 61 处把 ex.getMessage() 拼进用户可见字段(异常响应、任务 error_message、
结果作业 error_msg、看板 message),逐条翻译追不上新增速度,改为出口把关——
UserMessages.with(中文主干, 异常) 只拼接中文详情、orFallback(原文, 兜底句) 只放行含中文的串,
被换掉的原文进日志;GlobalExceptionHandler 按码分档兜底(401/4011/40902 各说各的话)。
另把 chunk-read-failed[N] 摘要写成"第 N 分片读取失败"、TASK_LOCK_BUSY 换成中文(40902 码不动,
客户端按码分支)。数字人两处与结果作业 worker 故意仍存原文:孤儿判定与三条 preserves raw
用例按 error_message 读它,界面侧由前端 userNotice 兜住,已在新尺子里点名豁免并反查豁免是否还被用到。

尺子:RawExceptionMessageSinkGuardTest(出口行数下限硬钉 1500+内存造违例自证)、UserMessagesTest、
UserFacingMessageChineseGuardTest 豁免表收到只剩 JSON 键 msg 一条。mvn -o test 4205 例 0 失败。
This commit is contained in:
2026-10-09 19:34:25 +08:00
parent 6325a63b52
commit 2a4d15b801
76 changed files with 1160 additions and 279 deletions
@@ -320,7 +320,7 @@ public class PublishTaskService {
public void submitResult(Long taskId, PublishSubmitResultRequest request) {
if (request == null || request.getFiles() == null || request.getFiles().isEmpty()) {
throw new BusinessException("files cannot be empty");
throw new BusinessException("文件列表不能为空");
}
if (request.getUserId() != null && request.getUserId() <= 0) {
throw new BusinessException("user_id 不合法");
@@ -328,7 +328,7 @@ public class PublishTaskService {
try (TaskDistributedLockService.LockHandle lock =
taskDistributedLockService.acquire(MODULE_TYPE, taskId)) {
if (lock == null) {
throw new BusinessException("task lock is busy");
throw new BusinessException("任务正被占用,请稍后重试");
}
List<String> uploadedPayloads = new ArrayList<>();
PreparedResultSubmission prepared;
@@ -534,17 +534,17 @@ public class PublishTaskService {
public void processResultFileJob(TaskFileJobEntity job) {
if (job == null || job.getTaskId() == null || job.getResultId() == null) {
throw new BusinessException("result file job arguments are incomplete");
throw new BusinessException("结果文件作业参数不完整");
}
FileTaskEntity task = fileTaskMapper.selectById(job.getTaskId());
if (task == null || !MODULE_TYPE.equals(task.getModuleType())) {
throw new BusinessException("task not found");
throw new BusinessException("任务不存在");
}
ensureTaskOwnedByCurrentInstance(task, "process publish result file");
FileResultEntity result = fileResultMapper.selectById(job.getResultId());
if (result == null || !MODULE_TYPE.equals(result.getModuleType())
|| !task.getId().equals(result.getTaskId())) {
throw new BusinessException("result record not found");
throw new BusinessException("结果记录不存在");
}
File workDirectory = FileUtil.mkdir(FileUtil.file(System.getProperty("java.io.tmpdir"),
@@ -556,7 +556,7 @@ public class PublishTaskService {
.toList();
if (successfulFiles.isEmpty()) {
markTaskAndResultFailed(task, result, "没有成功文件,无法生成结果");
throw new BusinessException("no successful publish files");
throw new BusinessException("没有发布成功的文件");
}
TaskOptions options = readTaskOptions(task);
@@ -1334,7 +1334,7 @@ public class PublishTaskService {
throw new BusinessException("请先上传 Excel 文件");
}
if (request.getPublishCountry() == null || request.getPublishCountry().isBlank()) {
throw new BusinessException("publish_country cannot be blank");
throw new BusinessException("发布国家不能为空");
}
}