Merge origin/main and preserve debug safeguards across trigger paths

This commit is contained in:
gitea committed 2026-10-15 14:56:11 +08:00
commit b605d7c2bb
7 files changed
+569 -61

No files matched your search

+22 -8
View File
@@ -662,26 +662,31 @@ export async function runWorkflowDebugTest(
client: import("ky").KyInstance,
pipelineId: string,
options: {
flowCodeOrId: string;
flowCodeOrId?: string;
data?: Record<string, any>;
triggerCategory?: import("./types.js").WorkflowTriggerCategory;
triggerType?: string;
triggerLabel?: string;
autoPublish?: boolean;
timeoutMs?: number;
pollIntervalMs?: number;
}
} = {}
): Promise<import("./types.js").WorkflowTestReport> {
if (!Number.isFinite(options.timeoutMs ?? 15000) || (options.timeoutMs ?? 15000) < 0 || !Number.isFinite(options.pollIntervalMs ?? 500) || (options.pollIntervalMs ?? 500) <= 0) {
throw new ValidationError("timeoutMs 必须为非负数,pollIntervalMs 必须为正数");
}
let targetEntityId = options.flowCodeOrId;
const isDirectCode = options.flowCodeOrId.includes("-") || options.flowCodeOrId.startsWith("ID01");
if (!isDirectCode) {
let targetEntityId = options.flowCodeOrId ?? "";
const code = options.flowCodeOrId;
const isDirectCode = !code || code.includes("-") || code.startsWith("ID01");
if (code && !isDirectCode) {
try {
const source = await api.getWorkflowDebugSource(client, pipelineId, {
page: 1,
pageSize: 10,
keywords: options.flowCodeOrId,
keywords: code,
});
const matched = source.items.find(
(item) => item.id === options.flowCodeOrId || item.title.includes(options.flowCodeOrId)
(item) => item.id === code || (item as any).code === code || item.title?.includes(code) || (item as any).name?.includes(code)
);
if (matched) {
targetEntityId = matched.id;
@@ -692,7 +697,8 @@ export async function runWorkflowDebugTest(
}
const jobId = await api.triggerWorkflowDebug(client, pipelineId, {
entityId: targetEntityId,
entityId: targetEntityId || undefined,
data: options.data,
autoPublish: options.autoPublish ?? false,
});
@@ -759,6 +765,9 @@ export async function runWorkflowDebugTest(
runType: finalJob?.runType || "DEBUG",
durationTime: typeof finalJob?.durationTime === "number" ? finalJob.durationTime : undefined,
targetEntityId,
triggerCategory: options.triggerCategory,
triggerType: options.triggerType,
triggerLabel: options.triggerLabel,
executionTree: tree,
failedExecutions: rawFailed,
conditionDiagnoses,
@@ -771,3 +780,8 @@ export {
type ConditionRuleExplanation,
} from "./workflow-branch.js";
export {
classifyWorkflowTrigger,
type WorkflowTriggerCategory,
} from "./types.js";