[GH-ISSUE #2802] [Issue]: Extension (and Mari workspace) import silently swallows failures — surface the real error/toast (privileged-gate 403 et al. are invisible to users) #1425

Closed
opened 2026-10-21 05:33:39 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @kolacheee on GitHub (Jun 22, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2802

Originally assigned to: @kolacheee on GitHub.

Summary

When an extension import fails, the error is swallowed to console.warn only and the user sees, at most, a generic "Failed to install 1 extension" toast with no reason — even though the client already holds the server's exact error message. The same silent-failure pattern exists on Professor Mari's workspace import/mutation handlers. The single most common real cause is the privileged-access gate returning 403 (e.g. accessing the app over a non-loopback address without an ADMIN_SECRET), but nothing in the UI says so, so users cannot self-diagnose.

This is an observability / UX bug. The 403 itself is intended security (extension install is a JS-injection route) — this issue is purely about making the failure visible and actionable, not about removing the gate.

Real user report (Arch + Firefox): "The extensions and mari package import things just silently fail for me. Other imports fine." — the lack of any toast/error is exactly why it was un-troubleshootable.

Symptom & UX impact

  • Importing an extension on a setup that hits the privileged gate (non-loopback access, no admin secret) fails with a generic/absent toast. Character / lorebook / preset imports work (they're not privilege-gated), so it looks like a broken install rather than an access issue.
  • The actual server message — e.g. "ADMIN_SECRET is required for privileged APIs", "Privileged API requires authenticated access", or "Invalid or missing X-Admin-Secret header" — only appears in the browser console ([ExtensionsSettings] Failed to import extension entry), which most users never open.
  • Net effect: a user-facing dead end on a core feature, with no breadcrumb toward the fix.

Root cause (file:line)

1. Extension import swallows the real error.
importExtensionEntries catches each failed install and only console.warns it, then shows a count-only toast:

// packages/client/src/components/panels/SettingsPanel.tsx:3878-3895
try {
  await createExtension.mutateAsync({ ...normalized, installedAt });
  imported++;
} catch (err) {
  failed++;
  console.warn("[ExtensionsSettings] Failed to import extension entry:", normalized.name, err); // :3886 — error discarded
}
// ...
if (failed > 0) {
  toast.warning(
    imported > 0
      ? `Installed ${imported} extension${imported === 1 ? "" : "s"} (${failed} failed).`
      : `Failed to install ${failed} extension${failed === 1 ? "" : "s"}.`,   // :3894 — no reason
  );
}

The caught err is an ApiError that already carries the server's message: ApiError is defined at packages/client/src/lib/api-client.ts:17 and thrown for api.post at :123-124 as new ApiError(res.status, body.error ?? res.statusText, body). So err.message / err.status are available — they are simply never shown.

2. Silently-skipped entries.
normalizeExtensionImportEntry returning null is continued with no count or message (SettingsPanel.tsx:3877), so a file with no importable entry can produce no feedback unless every entry is null.

3. Mari workspace path shares the pattern.
HomeProfessorMariChat.tsx has multiple workspace load/refresh/mutation handlers that swallow errors to console.error only or .catch(() => undefined) (e.g. :1608, :1633, :1640, :1644, :1650, :1810), so Mari-driven workspace imports/changes can fail with no user-facing toast — matching the "mari package import things just silently fail" half of the report.

(For context, the 403 originates from requirePrivilegedAccess in packages/server/src/middleware/privileged-gate.ts, applied to POST/PATCH/DELETE /extensions in extensions.routes.ts:24/30/41.)

Suggested fix

  • Surface the actual error. In importExtensionEntries, include the real message in the toast, e.g.:
    const message = err instanceof ApiError ? err.message : err instanceof Error ? err.message : String(err);
    toast.error(`Failed to install "${normalized.name}": ${message}`);
    
    (Aggregate per-entry messages, or surface the first, so the count-only warning is replaced/supplemented by the cause.)
  • Special-case the privileged-access 403 with actionable guidance. When err instanceof ApiError && err.status === 403, show something like: "Installing extensions requires loopback access or an admin secret. Open the app via localhost, or set ADMIN_SECRET on the server and enter it in Settings." This converts the dead-end into a fixable prompt.
  • Don't silently skip normalized === null. Count it and tell the user the file contained no importable extension entry.
  • Audit the Mari workspace import/mutation handlers in HomeProfessorMariChat.tsx for the same swallow (.catch(() => undefined) / console.error-only) and surface a toast on failure of a user-initiated action.

Affected files

  • packages/client/src/components/panels/SettingsPanel.tsx — importExtensionEntries (3868-3899), handleImportExtension (3901-3956)
  • packages/client/src/lib/api-client.ts — ApiError (17), api.post error path (123-124)
  • packages/client/src/components/chat/HomeProfessorMariChat.tsx — workspace import/mutation error handling
  • packages/server/src/middleware/privileged-gate.ts / packages/server/src/routes/extensions.routes.ts — context (the 403 whose message should be shown)

AI-investigated against released 2.0.0 (main); verify before fixing. Scope is error visibility only — the privileged-access 403 is intended behavior, separately surfaced to the affected user as a config step.

Originally created by @kolacheee on GitHub (Jun 22, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2802 Originally assigned to: @kolacheee on GitHub. ## Summary When an extension import fails, the error is **swallowed to `console.warn` only** and the user sees, at most, a generic *"Failed to install 1 extension"* toast with no reason — even though the client already holds the server's exact error message. The same silent-failure pattern exists on Professor Mari's workspace import/mutation handlers. The single most common real cause is the privileged-access gate returning **403** (e.g. accessing the app over a non-loopback address without an `ADMIN_SECRET`), but nothing in the UI says so, so users cannot self-diagnose. This is an **observability / UX** bug. The 403 itself is intended security (extension install is a JS-injection route) — this issue is purely about **making the failure visible and actionable**, not about removing the gate. > Real user report (Arch + Firefox): *"The extensions and mari package import things just silently fail for me. Other imports fine."* — the lack of any toast/error is exactly why it was un-troubleshootable. ## Symptom & UX impact - Importing an extension on a setup that hits the privileged gate (non-loopback access, no admin secret) fails with a generic/absent toast. Character / lorebook / preset imports work (they're not privilege-gated), so it looks like a broken install rather than an access issue. - The actual server message — e.g. *"ADMIN_SECRET is required for privileged APIs"*, *"Privileged API requires authenticated access"*, or *"Invalid or missing X-Admin-Secret header"* — only appears in the browser console (`[ExtensionsSettings] Failed to import extension entry`), which most users never open. - Net effect: a user-facing dead end on a core feature, with no breadcrumb toward the fix. ## Root cause (file:line) **1. Extension import swallows the real error.** `importExtensionEntries` catches each failed install and only `console.warn`s it, then shows a count-only toast: ```ts // packages/client/src/components/panels/SettingsPanel.tsx:3878-3895 try { await createExtension.mutateAsync({ ...normalized, installedAt }); imported++; } catch (err) { failed++; console.warn("[ExtensionsSettings] Failed to import extension entry:", normalized.name, err); // :3886 — error discarded } // ... if (failed > 0) { toast.warning( imported > 0 ? `Installed ${imported} extension${imported === 1 ? "" : "s"} (${failed} failed).` : `Failed to install ${failed} extension${failed === 1 ? "" : "s"}.`, // :3894 — no reason ); } ``` The caught `err` is an `ApiError` that already carries the server's message: `ApiError` is defined at `packages/client/src/lib/api-client.ts:17` and thrown for `api.post` at `:123-124` as `new ApiError(res.status, body.error ?? res.statusText, body)`. So `err.message` / `err.status` are available — they are simply never shown. **2. Silently-skipped entries.** `normalizeExtensionImportEntry` returning `null` is `continue`d with no count or message (`SettingsPanel.tsx:3877`), so a file with no importable entry can produce no feedback unless *every* entry is null. **3. Mari workspace path shares the pattern.** `HomeProfessorMariChat.tsx` has multiple workspace load/refresh/mutation handlers that swallow errors to `console.error` only or `.catch(() => undefined)` (e.g. `:1608`, `:1633`, `:1640`, `:1644`, `:1650`, `:1810`), so Mari-driven workspace imports/changes can fail with no user-facing toast — matching the "mari package import things just silently fail" half of the report. (For context, the 403 originates from `requirePrivilegedAccess` in `packages/server/src/middleware/privileged-gate.ts`, applied to `POST/PATCH/DELETE /extensions` in `extensions.routes.ts:24/30/41`.) ## Suggested fix - **Surface the actual error.** In `importExtensionEntries`, include the real message in the toast, e.g.: ```ts const message = err instanceof ApiError ? err.message : err instanceof Error ? err.message : String(err); toast.error(`Failed to install "${normalized.name}": ${message}`); ``` (Aggregate per-entry messages, or surface the first, so the count-only warning is replaced/supplemented by the cause.) - **Special-case the privileged-access 403 with actionable guidance.** When `err instanceof ApiError && err.status === 403`, show something like: *"Installing extensions requires loopback access or an admin secret. Open the app via localhost, or set `ADMIN_SECRET` on the server and enter it in Settings."* This converts the dead-end into a fixable prompt. - **Don't silently skip `normalized === null`.** Count it and tell the user the file contained no importable extension entry. - **Audit the Mari workspace import/mutation handlers** in `HomeProfessorMariChat.tsx` for the same swallow (`.catch(() => undefined)` / `console.error`-only) and surface a toast on failure of a user-initiated action. ## Affected files - `packages/client/src/components/panels/SettingsPanel.tsx` — `importExtensionEntries` (3868-3899), `handleImportExtension` (3901-3956) - `packages/client/src/lib/api-client.ts` — `ApiError` (17), `api.post` error path (123-124) - `packages/client/src/components/chat/HomeProfessorMariChat.tsx` — workspace import/mutation error handling - `packages/server/src/middleware/privileged-gate.ts` / `packages/server/src/routes/extensions.routes.ts` — context (the 403 whose message should be shown) --- *AI-investigated against released 2.0.0 (`main`); verify before fixing. Scope is error visibility only — the privileged-access 403 is intended behavior, separately surfaced to the affected user as a config step.*
Author
Owner

@SpicyMarinara commented on GitHub (Jun 22, 2026):

Addressed in PR #2790 / commit acab1fba: extension imports now surface the real first failure, including actionable privileged-access 403 guidance, invalid extension entries are counted, and Professor Mari workspace/status mutations now show screenshot-friendly failure toasts instead of console-only failures.

<!-- gh-comment-id:4772440941 --> @SpicyMarinara commented on GitHub (Jun 22, 2026): Addressed in PR #2790 / commit acab1fba: extension imports now surface the real first failure, including actionable privileged-access 403 guidance, invalid extension entries are counted, and Professor Mari workspace/status mutations now show screenshot-friendly failure toasts instead of console-only failures.
Author
Owner

@kolacheee commented on GitHub (Jun 22, 2026):

Implementing this (@kolacheee, already assigned). Draft PR opened against staging: #2803 — surfaces the real error/toast for extension imports (with an actionable admin-secret hint on the privileged-gate 403), counts silently-skipped entries, and adds failure toasts to Professor Mari's workspace approve/reject (their void call sites were swallowing rejections). (Note: PR targets staging, so GitHub won't auto-close this on merge — please close manually when #2803 lands.)

<!-- gh-comment-id:4772866946 --> @kolacheee commented on GitHub (Jun 22, 2026): Implementing this (@kolacheee, already assigned). Draft PR opened against `staging`: #2803 — surfaces the real error/toast for extension imports (with an actionable admin-secret hint on the privileged-gate 403), counts silently-skipped entries, and adds failure toasts to Professor Mari's workspace approve/reject (their `void` call sites were swallowing rejections). (Note: PR targets `staging`, so GitHub won't auto-close this on merge — please close manually when #2803 lands.)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#1425
No description provided.