fix: 完善工作流公共接口上传与错误契约

- 区分 HTTP 请求标识与内部上传标识,补齐 Redis 旧记录兼容和关联日志

- 保持归一化 MIME 一致,并隔离工作流鉴权错误契约对其他公共接口的影响

- 收口 Multipart 操作日志与对象存储故障分类,归档范围:S05
This commit is contained in:
2026-08-10 11:41:09 +08:00
parent bae7b18977
commit 9d2fa39a2d
16 changed files with 573 additions and 115 deletions

View File

@@ -32,6 +32,7 @@ import tech.easyflow.common.constant.Constants;
import tech.easyflow.common.domain.Result;
import tech.easyflow.common.entity.LoginAccount;
import tech.easyflow.common.satoken.util.SaTokenUtil;
import tech.easyflow.common.web.error.RequestIdContext;
import tech.easyflow.common.web.exceptions.BusinessException;
import tech.easyflow.common.web.jsonbody.JsonBody;
import tech.easyflow.publicapi.dto.PublicWorkflowInfo;
@@ -194,6 +195,7 @@ public class PublicWorkflowController {
multipartRequest.getMultiFileMap());
WorkflowApiPreparedUpload preparedUpload =
workflowApiUploadLifecycleService.prepare(
RequestIdContext.get(request),
workflow.getContent(),
metadata.getVariables(),
fileParts);
@@ -205,12 +207,12 @@ public class PublicWorkflowController {
topology,
executeId ->
workflowApiUploadLifecycleService.bindExecution(
preparedUpload.getRequestId(),
preparedUpload.getUploadId(),
executeId));
} catch (RuntimeException | Error error) {
try {
workflowApiUploadLifecycleService.abort(
preparedUpload.getRequestId());
preparedUpload.getUploadId());
} catch (RuntimeException cleanupError) {
error.addSuppressed(cleanupError);
}

View File

@@ -40,6 +40,12 @@ public class PublicApiInterceptor implements HandlerInterceptor {
String apiKey = request.getHeader("ApiKey");
if (apiKey == null || apiKey.isBlank()) {
if (!isWorkflowApi(requestURI)) {
Result<Void> failed = Result.fail(401, "密钥不正确");
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
ResponseUtil.renderJson(response, failed);
return false;
}
Result<PublicApiErrorDetail> failed = Result.fail(
"缺少 ApiKey 请求头",
new PublicApiErrorDetail(
@@ -62,4 +68,15 @@ public class PublicApiInterceptor implements HandlerInterceptor {
);
return true;
}
/**
* 判断是否为工作流公共 API避免专项错误契约影响其他公共接口。
*
* @param requestUri 请求 URI
* @return 是否为工作流公共 API
*/
private boolean isWorkflowApi(String requestUri) {
return requestUri != null
&& requestUri.contains("/public-api/workflow/");
}
}