Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(desktopDeepLinkListener): cover non-Error store rejections and owner error prefixes

Steven Enamakel8a33b3b50ce5
diff --git a/app/src/utils/__tests__/desktopDeepLinkListener.test.ts b/app/src/utils/__tests__/desktopDeepLinkListener.test.ts
index 254992ff4f..734a29aa9d 100644
--- a/app/src/utils/__tests__/desktopDeepLinkListener.test.ts
+++ b/app/src/utils/__tests__/desktopDeepLinkListener.test.ts
@@ -22,6 +22,12 @@ import { BILLING_DASHBOARD_URL } from '../links';
import { openUrl } from '../openUrl';
import { getSessionToken } from '../tauriCommands';
+const sentryCapture = vi.hoisted(() => vi.fn());
+vi.mock('@sentry/react', async importOriginal => ({
+ ...(await importOriginal<typeof import('@sentry/react')>()),
+ captureException: sentryCapture,
+}));
+
vi.mock('../configPersistence', () => ({ getStoredCoreMode: vi.fn() }));
vi.mock('../../services/coreRpcClient', () => ({
clearCoreRpcUrlCache: vi.fn(),
@@ -354,6 +360,22 @@ describe('desktopDeepLinkListener', () => {
expect(state.errorMessageKey).toBeNull();
});
+ // Sentry TAURI-REACT-1S: a rejection that is not an `Error` (a Tauri invoke
+ // rejects with whatever the command serialized) stringified to
+ // "[object Object]" and grouped under `auth store failed: other`.
+ it('reports a non-Error store rejection under its own PII-free kind', async () => {
+ sentryCapture.mockClear();
+ vi.mocked(storeSessionToken).mockRejectedValueOnce({ code: 42 });
+
+ vi.mocked(getCurrent).mockResolvedValue([authDeepLinkWithState('token=abc&key=auth')]);
+
+ await setupDesktopDeepLinkListener();
+ await waitForAuthSettled();
+
+ const captured = sentryCapture.mock.calls.map(([error]) => (error as Error).message);
+ expect(captured).toContain('auth store failed: non_error');
+ });
+
// The core cannot read its own config.toml: permanent, host-side, and
// identical for every config-dependent RPC. It previously fell through to the
// generic "Please try again", which is advice that can never work. The copy is
@@ -524,6 +546,39 @@ describe('classifyAuthStoreFailure', () => {
expect(classifyAuthStoreFailure(message)).toBe(expected);
});
+ // Sentry TAURI-REACT-1S: the session owner's own prefixes (Rust
+ // `SessionError`: `CORE:` / `BACKEND:` / `INVALID:`) and the listener's own
+ // fail-closed error all collapsed into `other`.
+ it.each([
+ ['CORE: auth.set_credential failed: boom', 'core'],
+ ['BACKEND: could not resolve the backend URL', 'backend'],
+ ['INVALID: a local session needs a user payload', 'invalid'],
+ [
+ 'CORE: session owner reported success but the core holds no session token',
+ 'core_no_session_token',
+ ],
+ ])('classifies the owner error %j as %s', (message, expected) => {
+ expect(classifyAuthStoreFailure(message)).toBe(expected);
+ });
+
+ it('keeps specific buckets ahead of the CORE: prefix', () => {
+ expect(classifyAuthStoreFailure('CORE: core RPC operation timed out')).toBe('auth_me_timeout');
+ expect(
+ classifyAuthStoreFailure(
+ 'CORE: Failed to read config file: /x/config.toml: Permission denied (os error 13)'
+ )
+ ).toBe('config_unreadable');
+ });
+
+ it('classifies non-Error rejections without stringifying them', () => {
+ expect(classifyAuthStoreFailure({ code: 42 })).toBe('non_error');
+ expect(classifyAuthStoreFailure(undefined)).toBe('non_error');
+ expect(classifyAuthStoreFailure(null)).toBe('non_error');
+ // A serialized error object still carries a classifiable message.
+ expect(classifyAuthStoreFailure({ message: 'CORE: boom' })).toBe('core');
+ expect(classifyAuthStoreFailure(new Error('INVALID: no user'))).toBe('invalid');
+ });
+
// Contract pin: the classifier matches substrings of the Rust-produced error
// (credentials/ops.rs: `Session validation failed (GET /auth/me): {reason}`,
// with {reason} from rest.rs `GET /auth/me failed ({status}): {text}` or a
diff --git a/vendor/tinybus b/vendor/tinybus
index 722f00706c..9a015b34b5 160000
--- a/vendor/tinybus
+++ b/vendor/tinybus
@@ -1 +1 @@
-Subproject commit 722f00706cb2faf263692181a476f655871acd94
+Subproject commit 9a015b34b54e2fe6bc71e1af35f5cd3d1367868f