feat(sql-file): show all execution failures

This commit is contained in:
Guoyu Su authored and GitHub committed 2026-09-03 01:12:25 +08:00
1 parent 460b413da8
commit a13a7302fa
6 files changed
+414 -20

No files matched your search

@@ -232,9 +232,17 @@ function toggleFailureDetails(exportId: string) {
}
function failureDetailCount(task: ExportTask) {
if (task.kind === "sql-file") return (task.sqlFileFailures?.length ?? 0) + (task.sqlFileFailuresOmitted ?? 0);
return (task.transferFailures?.length ?? 0) + (task.transferFailuresOmitted ?? 0);
}
function hasUnlistedTaskError(task: ExportTask) {
if (task.status !== "Error" || !task.errorMessage) return false;
if (task.kind === "sql-file") return !(task.sqlFileFailures ?? []).some((failure) => failure.error === task.errorMessage);
if (task.kind === "data-transfer") return !(task.transferFailures ?? []).some((failure) => failure.error === task.errorMessage);
return true;
}
function openTask(task: ExportTask): void {
task.onOpen?.();
}
@@ -288,21 +296,35 @@ function openTask(task: ExportTask): void {
<span class="break-words tabular-nums">{{ rowsText(task) }}</span>
<span v-if="task.kind !== 'data-transfer' && task.startedAt !== undefined" class="ml-1 tabular-nums">{{ elapsedText(task) }}</span>
<span v-if="taskStatusText(task)" class="ml-1 font-medium text-primary">{{ taskStatusText(task) }}</span>
<span v-if="task.status === 'Error' && task.errorMessage" class="mt-1 block whitespace-normal break-words text-destructive" :title="translateBackendError(t, task.errorMessage)">
{{ translateBackendError(t, task.errorMessage) }}
<span v-if="hasUnlistedTaskError(task)" class="mt-1 block whitespace-normal break-words text-destructive" :title="translateBackendError(t, task.errorMessage!)">
{{ translateBackendError(t, task.errorMessage!) }}
</span>
<template v-if="task.kind === 'data-transfer' && failureDetailCount(task) > 0">
<template v-if="(task.kind === 'data-transfer' || task.kind === 'sql-file') && failureDetailCount(task) > 0">
<button class="mt-1.5 flex items-center gap-1 text-xs font-medium text-foreground hover:text-primary" :aria-expanded="failureDetailsExpanded(task.exportId)" @click="toggleFailureDetails(task.exportId)">
<ChevronRight class="h-3.5 w-3.5 shrink-0 transition-transform" :class="{ 'rotate-90': failureDetailsExpanded(task.exportId) }" />
{{ failureDetailsExpanded(task.exportId) ? t("exportProgress.hideFailureDetails") : t("exportProgress.showFailureDetails", { count: failureDetailCount(task) }) }}
</button>
<div v-if="failureDetailsExpanded(task.exportId)" class="mt-1.5 max-h-44 overflow-y-auto rounded border border-destructive/20 bg-destructive/5">
<div v-for="failure in task.transferFailures" :key="failure.table" class="border-b border-destructive/15 px-2.5 py-2 last:border-b-0">
<div class="break-all font-mono font-medium text-foreground">{{ failure.table }}</div>
<div class="mt-0.5 select-text whitespace-pre-wrap break-words text-destructive">{{ failure.error }}</div>
<div v-if="failure.truncated" class="mt-0.5 text-muted-foreground">{{ t("exportProgress.failureDetailTruncated") }}</div>
</div>
<div v-if="task.transferFailuresOmitted" class="px-2.5 py-2 text-muted-foreground">{{ t("exportProgress.failureDetailsOmitted", { count: task.transferFailuresOmitted }) }}</div>
<template v-if="task.kind === 'data-transfer'">
<div v-for="failure in task.transferFailures" :key="failure.table" class="border-b border-destructive/15 px-2.5 py-2 last:border-b-0">
<div class="break-all font-mono font-medium text-foreground">{{ failure.table }}</div>
<div class="mt-0.5 select-text whitespace-pre-wrap break-words text-destructive">{{ failure.error }}</div>
<div v-if="failure.truncated" class="mt-0.5 text-muted-foreground">{{ t("exportProgress.failureDetailTruncated") }}</div>
</div>
<div v-if="task.transferFailuresOmitted" class="px-2.5 py-2 text-muted-foreground">{{ t("exportProgress.failureDetailsOmitted", { count: task.transferFailuresOmitted }) }}</div>
</template>
<template v-else>
<div v-for="failure in task.sqlFileFailures" :key="`${failure.fileIndex ?? -1}:${failure.statementIndex}`" class="border-b border-destructive/15 px-2.5 py-2 last:border-b-0">
<div class="flex min-w-0 items-center gap-1.5 font-medium text-foreground">
<span class="shrink-0">#{{ failure.statementIndex }}</span>
<span v-if="failure.fileName" class="truncate text-muted-foreground" :title="failure.fileName">{{ failure.fileName }}</span>
</div>
<div v-if="failure.statementSummary" class="mt-0.5 select-text whitespace-pre-wrap break-words font-mono text-foreground">{{ failure.statementSummary }}</div>
<div class="mt-0.5 select-text whitespace-pre-wrap break-words text-destructive">{{ translateBackendError(t, failure.error) }}</div>
<div v-if="failure.truncated" class="mt-0.5 text-muted-foreground">{{ t("exportProgress.failureDetailTruncated") }}</div>
</div>
<div v-if="task.sqlFileFailuresOmitted" class="px-2.5 py-2 text-muted-foreground">{{ t("exportProgress.failureDetailsOmitted", { count: task.sqlFileFailuresOmitted }) }}</div>
</template>
</div>
</template>
</div>
@@ -281,6 +281,45 @@ describe("ExportProgressPopover task duration", () => {
expect(document.body.textContent).toContain("1 additional failure detail(s) not shown");
expect(document.body.textContent).not.toContain("failure 100");
});
it("keeps SQL-file statement failures inspectable after a successful continue-on-error run", async () => {
const tracker = useExportTracker();
const task = tracker.addSqlFileTask("sql-failure-details", "migration.sql", "/tmp/migration.sql");
tracker.updateSqlFileTask(task.exportId, {
executionId: task.exportId,
status: "statementFailed",
statementIndex: 7,
successCount: 6,
failureCount: 1,
affectedRows: 6,
elapsedMs: 10,
statementSummary: "ALTER TABLE users ADD missing_type",
error: "type missing_type does not exist",
});
tracker.updateSqlFileTask(task.exportId, {
executionId: task.exportId,
status: "done",
statementIndex: 8,
successCount: 7,
failureCount: 1,
affectedRows: 7,
elapsedMs: 12,
statementSummary: "INSERT INTO users VALUES (1)",
error: null,
});
await mountPopover();
expect(document.body.textContent).toContain("7 succeeded, 1 failed");
const detailsButton = document.body.querySelector<HTMLButtonElement>('button[aria-expanded="false"]');
expect(detailsButton?.textContent).toContain("Failure details (1)");
detailsButton?.click();
await nextTick();
expect(document.body.textContent).toContain("#7");
expect(document.body.textContent).toContain("ALTER TABLE users ADD missing_type");
expect(document.body.textContent).toContain("type missing_type does not exist");
});
});
describe("ExportProgressPopover file name and reveal action", () => {