Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Update copyable error reports
Leendert de Borst715b917c16a7
diff --git a/apps/browser-extension/src/entrypoints/popup/components/VaultErrorReport.tsx b/apps/browser-extension/src/entrypoints/popup/components/VaultErrorReport.tsxindex 92d1bd7f6..641b22190 100644--- a/apps/browser-extension/src/entrypoints/popup/components/VaultErrorReport.tsx+++ b/apps/browser-extension/src/entrypoints/popup/components/VaultErrorReport.tsx@@ -36,6 +36,7 @@ const VaultErrorReport: React.FC<VaultErrorReportProps> = ({ error }) => {`Extension: ${AppInfo.VERSION}`,`Browser: ${navigator.userAgent}`,`Error: ${error.message || t('common.errors.unknownError')}`,+ ...(error.detail ? [`Detail: ${error.detail}`] : []),'','Stack trace:',error.stack ?? 'No stack trace available',diff --git a/apps/browser-extension/src/entrypoints/popup/pages/auth/Login.tsx b/apps/browser-extension/src/entrypoints/popup/pages/auth/Login.tsxindex 0e2315860..1a491e2b7 100644--- a/apps/browser-extension/src/entrypoints/popup/pages/auth/Login.tsx+++ b/apps/browser-extension/src/entrypoints/popup/pages/auth/Login.tsx@@ -4,7 +4,7 @@ import { VaultProcessingError } from '@aliasvault/client/api/errors/VaultProcessimport { describeAuthError, formatErrorMessage } from '@aliasvault/client/auth/AuthErrorMessage';import { VaultKeyService } from '@aliasvault/client/auth/VaultKeyService';import { AppInfo } from '@aliasvault/client/platform/AppInfo';-import { syncErrorMessage } from '@aliasvault/client/sync/SyncErrorMessage';+import { syncErrorMessage, syncErrorReportDetail } from '@aliasvault/client/sync/SyncErrorMessage';import React, { useEffect, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';import { useNavigate } from 'react-router-dom';@@ -84,7 +84,7 @@ const Login: React.FC = () => {throw new ServerUpdateRequiredError();}if (!result.success) {- throw new VaultProcessingError('vault-pull', new Error(syncErrorMessage(result, t) ?? t('common.errors.unknownError')));+ throw new VaultProcessingError('vault-pull', new Error(syncErrorMessage(result, t) ?? t('common.errors.unknownError')), syncErrorReportDetail(result));}await dbContext.loadStoredDatabase();@@ -148,7 +148,7 @@ const Login: React.FC = () => {return;case 'vaultPullFailed':// The vault was fetched but couldn't be decrypted/materialized, surface the real error (copyable) for support.- setVaultError(new VaultProcessingError('vault-pull', new Error(syncErrorMessage(result.sync, t) ?? t('common.errors.unknownError'))));+ setVaultError(new VaultProcessingError('vault-pull', new Error(syncErrorMessage(result.sync, t) ?? t('common.errors.unknownError')), syncErrorReportDetail(result.sync)));return;case 'logout':setError(result.message ?? t(result.reasonKey ?? 'common.errors.unknownError'));diff --git a/apps/browser-extension/tests/e2e/80-vault-errors.spec.ts b/apps/browser-extension/tests/e2e/80-vault-errors.spec.tsindex dc3e36c9d..737a6f5c4 100644--- a/apps/browser-extension/tests/e2e/80-vault-errors.spec.ts+++ b/apps/browser-extension/tests/e2e/80-vault-errors.spec.ts@@ -12,7 +12,7 @@ import type { Page } from '@playwright/test';const SERVER_NOT_AVAILABLE_MESSAGE = 'The AliasVault server is not available.';/**- * Check the login page shows the copyable vault error report with the given code.+ * Check the login page shows the copyable vault error report with the given code and the engine's technical detail.*/async function expectVaultErrorReport(popup: Page, code: string, detail: string): Promise<void> {const report = popup.locator('#vault-error-report');@@ -27,12 +27,12 @@ async function expectVaultErrorReport(popup: Page, code: string, detail: string)}/**- * Check the popup shows the sync failure dialog with the materialize error and its code.+ * Check the popup shows the sync failure dialog with the materialize error code, without the engine's technical detail.*/async function expectSyncFailedDialog(popup: Page): Promise<void> {await expect(popup.getByRole('heading', { name: 'Sync failed' })).toBeVisible({ timeout: Timeouts.LONG });await expect(popup.getByText('(Code: E-508)')).toBeVisible();- await expect(popup.getByText('NOT NULL constraint failed')).toBeVisible();+ await expect(popup.getByText('NOT NULL constraint failed')).toHaveCount(0);await expect(popup.getByText(SERVER_NOT_AVAILABLE_MESSAGE)).toHaveCount(0);}diff --git a/apps/web/src/pages/sync/Sync.tsx b/apps/web/src/pages/sync/Sync.tsxindex 4095227e8..312056914 100644--- a/apps/web/src/pages/sync/Sync.tsx+++ b/apps/web/src/pages/sync/Sync.tsx@@ -1,6 +1,6 @@import { VaultVersionIncompatibleError } from '@aliasvault/client/api/errors/VaultVersionIncompatibleError';import { AppInfo } from '@aliasvault/client/platform/AppInfo';-import { syncErrorMessage } from '@aliasvault/client/sync/SyncErrorMessage';+import { syncErrorMessage, syncErrorReport } from '@aliasvault/client/sync/SyncErrorMessage';import { VaultMigrationKind } from '@aliasvault/client/sync/VaultManifestMigration';import { VaultSqlGenerator, type VaultVersion } from '@aliasvault/vault';import React, { useCallback, useEffect, useRef, useState } from 'react';@@ -101,7 +101,7 @@ const Sync: React.FC = () => {// A local schema rebuild is invisible to the user and runs unattended.const result = await vaultStore.migrateVaultManifest();if (!result.success) {- setErrorDetails(syncErrorMessage(result, t) ?? null);+ setErrorDetails(syncErrorReport(result, t) ?? null);setStatus('decryption-failed');return;}@@ -156,7 +156,7 @@ const Sync: React.FC = () => {return;}if (!result.success) {- setErrorDetails(syncErrorMessage(result, t) ?? null);+ setErrorDetails(syncErrorReport(result, t) ?? null);setStatus('decryption-failed');return;}diff --git a/core/client/src/api/errors/VaultProcessingError.ts b/core/client/src/api/errors/VaultProcessingError.tsindex 57b5c38f8..f796755d7 100644--- a/core/client/src/api/errors/VaultProcessingError.ts+++ b/core/client/src/api/errors/VaultProcessingError.ts@@ -10,17 +10,22 @@ export class VaultProcessingError extends Error {/** The original error that caused this failure (kept for logging / inspection). */public readonly originalError: unknown;+ /** Technical detail for the copyable report only, not shown in the message. */+ public readonly detail?: string;+/*** Creates a new instance of VaultProcessingError.* @param source - a short identifier of the flow that failed (included in the copyable report).* @param originalError - the underlying error whose message + stack are preserved.+ * @param detail - technical detail for the copyable report only.*/- public constructor(source: string, originalError: unknown) {+ public constructor(source: string, originalError: unknown, detail?: string) {const causeMessage = originalError instanceof Error ? originalError.message : String(originalError);super(causeMessage);this.name = 'VaultProcessingError';this.source = source;this.originalError = originalError;+ this.detail = detail;// Preserve the original stack so the copyable report points at the real failure site, not this wrapper.if (originalError instanceof Error && originalError.stack) {diff --git a/core/client/src/sync/SyncErrorMessage.ts b/core/client/src/sync/SyncErrorMessage.tsindex 460a0929f..62afc3401 100644--- a/core/client/src/sync/SyncErrorMessage.ts+++ b/core/client/src/sync/SyncErrorMessage.ts@@ -34,3 +34,26 @@ export function syncErrorMessage(detail: SyncErrorDetail, t: (key: string) => st}return detail.error;}++/**+ * The engine's technical detail that {@link syncErrorMessage} leaves out, for a copyable error report.+ * @param detail - the sync outcome+ */+export function syncErrorReportDetail(detail: SyncErrorDetail): string | undefined {+ if (detail.logoutReason || !detail.errorCode || !detail.error) {+ return undefined;+ }+ const code = isErrorCode(detail.errorCode) ? detail.errorCode : AppErrorCode.UNKNOWN_ERROR;+ return hasOwnErrorMessage(code) ? detail.error : undefined;+}++/**+ * The copyable report for a failed sync: the message, followed by the engine's technical detail on its own line.+ * @param detail - the sync outcome+ * @param t - the renderer's translation function+ */+export function syncErrorReport(detail: SyncErrorDetail, t: (key: string) => string): string | undefined {+ const message = syncErrorMessage(detail, t);+ const technicalDetail = syncErrorReportDetail(detail);+ return message && technicalDetail ? `${message}\n${technicalDetail}` : message;+}