mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2770] [Issue]: Connection/preset save-failure swallowing — handleSave never re-throws, so close/test/save-and-close proceed on a failed save (silent data loss) #1409
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#1409
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kolacheee on GitHub (Jun 21, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2770
Originally assigned to: @SpicyMarinara on GitHub.
Summary
Multiple editors treat
await handleSave()/.mutate(...)as if a failed save aborts the next action, but the save handlers catch their own error and resolve normally (or fire-and-forget), so close/test/export proceed on a failed save and edits are silently lost with no error surfaced.Sub-bug 1: ConnectionEditor test actions run after a swallowed save (new-bug)
(a) All five action handlers gate on
if (dirty) { try { await handleSave(); } catch { return; } }, buthandleSavecatches its mutation error and only callssetSaveErrorthen returns — never re-throws. So thecatch { return }is dead code and Test/Message/Fetch-Models/Diagnose/Test-Image run against the UN-updated server record, reporting success for settings that were never persisted.(b) Set maxContext=0 (or a bad Base URL), click Test Connection -> save 400s silently, a green 'Success' card appears for unsaved settings.
(c) ConnectionEditor.tsx:379-441 (handleSave catch at 439-441, no re-throw), 583-707 (the five handlers). Kind: new-bug.
Sub-bug 2: ConnectionEditor 'Save & close' closes on failed save (new-bug)
(a)
async () => { await handleSave(); closeConnectionDetail(); }— since handleSave never throws, close runs unconditionally; the editor unmounts before the saveError banner shows and all local edits are discarded.(c) ConnectionEditor.tsx:830-838, 439-441. Kind: new-bug.
Sub-bug 3: PresetEditor 'Save & close' closes before mutation resolves (data-loss/new-bug)
(a) Save & close calls
handleSave()(fire-and-forget.mutate, onSuccess only, no onError) thenclosePresetDetail()synchronously. On a 400 (e.g. empty name) nothing persists, the editor unmounts, and all unsaved Overview edits are lost with no error. (Success path is harmless — the in-flight PATCH still completes.)(c) PresetEditor.tsx:436-444, 237-256. Kind: new-bug.
Sub-bug 4: Empty/invalid name & variable fields fail silently (validation/new-bug)
(a) Clearing the preset name, or emptying/over-filling a variable name/question/separator, sends a PATCH the server rejects (min(1)/max(...));
useUpdatePreset/useUpdateVariablehave only onSuccess (no onError), and the global QueryClient has no mutation error handler, so the failure is silent. The success-path invalidation never runs, so other unsaved edits are also dropped and the bad value sticks in the controlled input.(c) PresetEditor.tsx:363-372 (name input), 2050-2071 (var name), 2134-2156 (question), 1813-1819 (separator); prompt.schema.ts:149/103-112; use-presets.ts:86-97/289-303; main.tsx:13-21. Kind: new-bug (validation).
Suggested Fix
setSaveError(msg); throw err;(or return a boolean) so the existingcatch { return }/ close guards work. Gate close on success.Template
pnpm checkpassesAffected files
packages/client/src/components/connections/ConnectionEditor.tsxpackages/client/src/components/presets/PresetEditor.tsxpackages/client/src/hooks/use-presets.tspackages/client/src/hooks/use-connections.tsAudit provenance
Found by a multi-agent re-review of the connection/preset subsystem (editors UI + send-pipeline) against the merged
stagingtree (Round 1 + round-2 gap sweep + completeness critic, each finding adversarially verified). The prior #2656-#2668 fixes were re-verified as HELD on their primary paths. Severity: MEDIUM.@SpicyMarinara commented on GitHub (Jun 21, 2026):
Fixed in PR #2747.\n\nWhat changed:\n- ConnectionEditor handleSave now rethrows after setting saveError, so Test Connection/Test Message/Diagnose/Test Image/Fetch Models and Save & close abort when the save fails.\n- ConnectionEditor Save & close catches failed saves and keeps the editor open.\n- PresetEditor handleSave now uses mutateAsync, validates empty preset names client-side, and only shows the saved state after the PATCH succeeds.\n- PresetEditor Save & close awaits save success before closing and keeps the editor open on failure.\n- Preset update and variable create/update mutations now surface validation failures with toast errors instead of failing silently.\n\nDeferred pnpm/check validation until the end of the issue sweep per maintainer request.