fix(secrets): unlock Secret Service items on retry

Closes #11052
This commit is contained in:
t8y2 committed 2026-10-04 16:33:11 +00:00
1 parent 320e37aa42
commit 75c9122799
11 files changed
+220 -23

No files matched your search

@@ -31,6 +31,8 @@ describe("migration failure actions", () => {
button("migration.retryStatus").click();
await nextTick();
expect(backend.migrationStatus).toHaveBeenCalledTimes(2);
expect(backend.migrationStatus).toHaveBeenNthCalledWith(1, false);
expect(backend.migrationStatus).toHaveBeenNthCalledWith(2, true);
expect(backend.migrationRetry).not.toHaveBeenCalled();
} finally {
app.unmount();
@@ -148,7 +148,7 @@ async function diagnostic() {
<p>{{ t(errorAdviceKey) }}</p>
</div>
<div class="flex flex-wrap gap-3">
<button v-if="props.store.state.error === 'statusFailed' || (status?.keyProviderAvailable === false && !status?.keyCreationAllowed)" class="rounded-md bg-primary px-4 py-2 text-primary-foreground disabled:opacity-50" :disabled="props.store.state.busy" @click="props.store.initialize">
<button v-if="props.store.state.error === 'statusFailed' || (status?.keyProviderAvailable === false && !status?.keyCreationAllowed)" class="rounded-md bg-primary px-4 py-2 text-primary-foreground disabled:opacity-50" :disabled="props.store.state.busy" @click="props.store.retryStatus">
{{ t("migration.retryStatus") }}</button
><button
v-else
@@ -173,7 +173,7 @@ async function diagnostic() {
<p class="mt-3 text-sm text-muted-foreground">{{ props.store.state.error ? t(errorAdviceKey) : t("migration.progress") }}</p>
</div>
<div v-if="props.store.state.error" class="flex flex-wrap gap-3">
<button class="rounded-md bg-primary px-4 py-2 text-primary-foreground disabled:opacity-50" :disabled="props.store.state.busy" @click="props.store.state.error === 'statusFailed' ? props.store.initialize() : props.store.retry()">
<button class="rounded-md bg-primary px-4 py-2 text-primary-foreground disabled:opacity-50" :disabled="props.store.state.busy" @click="props.store.state.error === 'statusFailed' ? props.store.retryStatus() : props.store.retry()">
{{ props.store.state.busy ? t("migration.running") : props.store.state.error === "statusFailed" ? t("migration.retryStatus") : t("migration.retryMigration") }}</button
><button class="rounded-md border px-4 py-2 disabled:opacity-50" :disabled="props.store.state.busy" @click="diagnostic">{{ t("migration.exportDiagnostic") }}</button
><button class="rounded-md border px-4 py-2 disabled:opacity-50" :disabled="props.store.state.busy" @click="exitApp">{{ t("migration.exit") }}</button>
@@ -125,6 +125,17 @@ describe("WebDAV sync HTTP API", () => {
await expect(migrationCleanupBackups()).resolves.toBeUndefined();
expect(lastCall(fetchMock)).toEqual({ url: "/api/migration/cleanup-backups", body: {} });
});
it("forwards explicit migration status retries to the Web backend", async () => {
const fetchMock = stubFetch({});
const { migrationStatus } = await import("@/lib/backend/http");
await migrationStatus();
await migrationStatus(true);
expect(fetchMock).toHaveBeenNthCalledWith(1, "/api/migration/status");
expect(fetchMock).toHaveBeenNthCalledWith(2, "/api/migration/status?retry=true");
});
});
describe("GitLab snippet sync HTTP API", () => {
+1 -1
View File
@@ -205,7 +205,7 @@ import type { PluginToolPreview } from "@/types/pluginAiTools";
import type { CsvQuoteMode } from "@/lib/export/csvQuoteMode";
import type { MigrationPreflight, MigrationReport } from "./migration";
export type { MigrationPreflight, MigrationReport } from "./migration";
export const migrationStatus = (): Promise<MigrationPreflight> => get("/api/migration/status");
export const migrationStatus = (retry = false): Promise<MigrationPreflight> => get(`/api/migration/status${retry ? "?retry=true" : ""}`);
export const migrationStart = (): Promise<MigrationReport> => post("/api/migration/start", {});
export const migrationRetry = (): Promise<MigrationReport> => post("/api/migration/retry", {});
export const migrationCleanupBackups = (): Promise<void> => post("/api/migration/cleanup-backups", {});
+1 -1
View File
@@ -36,7 +36,7 @@ function invoke<T>(command: string, args?: Record<string, unknown>): Promise<T>
import type { MigrationPreflight, MigrationReport } from "./migration";
export type { MigrationPreflight, MigrationReport } from "./migration";
export const migrationStatus = (): Promise<MigrationPreflight> => invoke("migration_status");
export const migrationStatus = (retry = false): Promise<MigrationPreflight> => invoke("migration_status", { retry });
export const migrationStart = (): Promise<MigrationReport> => invoke("migration_start");
export const migrationRetry = (): Promise<MigrationReport> => invoke("migration_retry");
export const migrationCleanupBackups = (): Promise<void> => invoke("migration_cleanup_backups");
+4 -2
View File
@@ -74,9 +74,11 @@ describe("migration store", () => {
expect(store.state.error).toBe("statusFailed");
expect(store.state.errorCode).toBeNull();
expect(store.state.errorMessage).toBeNull();
await store.initialize();
await store.retryStatus();
expect(store.state.error).toBeNull();
expect(store.completed.value).toBe(true);
expect(status).toHaveBeenNthCalledWith(1, false);
expect(status).toHaveBeenNthCalledWith(2, true);
});
it("discards arbitrary transport exception values in state and diagnostics", async () => {
const secret = "password=DO_NOT_EXPOSE";
@@ -194,7 +196,7 @@ describe("migration store", () => {
await store.initialize();
await store.start();
expect(store.state.error).toBe("statusFailed");
await store.initialize();
await store.retryStatus();
expect(store.completed.value).toBe(true);
expect(store.state.report).toBeNull();
expect(store.blocking.value).toBe(true);
+7 -5
View File
@@ -32,18 +32,18 @@ export function useMigrationStore(backend: MigrationApi = api) {
state.errorCode = null;
state.errorMessage = null;
}
async function refreshStatus() {
async function refreshStatus(retry = false) {
// Only this endpoint returns classified, redacted migration errors. Transport
// exceptions may contain configuration values and must never enter UI state.
state.status = await backend.migrationStatus();
state.status = await backend.migrationStatus(retry);
state.errorCode = state.status.errorCode ?? null;
state.errorMessage = state.status.errorMessage ?? null;
}
async function initialize() {
async function checkStatus(retry: boolean) {
state.loading = true;
clearError();
try {
await refreshStatus();
await refreshStatus(retry);
state.step = completed.value ? 3 : 1;
// A completed migration only needs the success page in the session that
// performed it. On later launches, retained backups are recovery assets,
@@ -57,6 +57,8 @@ export function useMigrationStore(backend: MigrationApi = api) {
state.loading = false;
}
}
const initialize = () => checkStatus(false);
const retryStatus = () => checkStatus(true);
async function run(retry: boolean) {
if (state.busy) return;
state.busy = true;
@@ -114,5 +116,5 @@ export function useMigrationStore(backend: MigrationApi = api) {
function enter() {
if (completed.value && !state.busy) state.entered = true;
}
return { state, blocking, completed, initialize, start: () => run(false), retry: () => run(true), cleanup, diagnostic, enter };
return { state, blocking, completed, initialize, retryStatus, start: () => run(false), retry: () => run(true), cleanup, diagnostic, enter };
}