[GH-ISSUE #2773] [Issue]: Connection/preset number & URL input validation gaps + chat-settings preset reset/reconcile gaps #1410

Closed
opened 2026-10-21 05:33:22 +07:00 by bsakaguchi · 1 comment
Owner

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

Originally assigned to: @SpicyMarinara on GitHub.

Summary

Client-side number/URL inputs lack validation matching the server schema (a bad value blocks the entire save with a generic error), the ParamInput display can desync from the saved value, and the chat-settings-preset selector has reset/reconcile gaps including a presetChoices clobber.

Sub-bug 1: Max Context allows 0 (new-bug)

(a) The Max Context DraftNumberInput is min={0}; committing 0 yields maxContext:0 in the PATCH, which the server z.number().int().min(1) rejects -> 400 -> the WHOLE connection save aborts (name/key/model/params lost) with a generic 'Save failed' and no field-level hint.
(c) ConnectionEditor.tsx:1556-1565/389/416-441; DraftNumberInput.tsx:53-71; connection.schema.ts:29. Kind: new-bug.

Sub-bug 2: Base URL / Embedding URL no validation (new-bug)

(a) Bare host:port / scheme-less URLs (common for local models, e.g. 192.168.1.5:8080) fail the server .url() and block the whole save with a generic banner and no field highlight. (Note: localhost:11434/v1 actually passes Zod, contrary to the original example.)
(c) ConnectionEditor.tsx:1086-1101/1875-1883/387/395; connection.schema.ts:25/36. Kind: new-bug.

Sub-bug 3: ParamInput stale display (new-bug)

(a) On out-of-range/empty entry, ParamInput.commit only setError — never onChange and never reverts draft to value. The box keeps showing the rejected value while the parent/saved value stays the old one, so the display lies about what will be saved (no corruption).
(c) GenerationParametersEditor.tsx:516-554. Kind: new-bug (low).

Sub-bug 4-5: Chat-settings-preset reset/reconcile no-ops (ux/validation)

(a) When appliedChatPresetId is null OR points at a deleted preset, selectedChatPreset falls back to the Default preset, so the dropdown shows 'Default' but handleSelectPreset's id === selectedChatPreset?.id guard makes selecting Default a no-op — the chat can't be reset and a dangling dead id is never cleared.
(c) ChatSettingsDrawer.tsx:2149-2156/2401-2404; chat-presets.storage.ts:261-309. Kind: new-bug (medium).

Sub-bug 6: presetChoices clobber on chat-preset apply (data-loss/missed-instance)

(a) snapshotCurrentPresetSettings captures the whole metadata incl. presetChoices (per-chat variable answers, keyed by variableName). presetChoices is NOT in CHAT_PRESET_EXCLUDED_METADATA_KEYS, so it's stored in the chat-settings preset and, on apply, overwrites the target chat's own choices (it's not in the preserved set) -> wrong/garbage variable values injected at serialization. The sibling per-chat agentVariables IS excluded, showing presetChoices was simply missed.
(c) ChatSettingsDrawer.tsx:2393-2399/2411-2459; chat-presets.storage.ts:88/277-298; chat-preset.ts:45-112. Kind: missed-instance (medium).

Suggested Fix

  • Max Context input min={1} (or clamp <1 in payload); add field-level validation surfacing.
  • Validate Base/Embedding URL client-side (accept empty or parseable URL; optionally auto-prefix http://); show field-level error.
  • ParamInput: on invalid, revert draft to String(value) or clamp+commit.
  • Distinguish 'explicitly applied' from 'Default fallback' in handleSelectPreset; allow the Default selection to perform a real reset and clear a dangling appliedChatPresetId.
  • Add presetChoices to CHAT_PRESET_EXCLUDED_METADATA_KEYS.

Template

  • Max Context / URL inputs validated client-side with field-level errors
  • ParamInput display matches saved value
  • Selecting Default resets a customized/dangling chat
  • presetChoices excluded from chat-settings presets
  • pnpm check passes

Affected files

  • packages/client/src/components/connections/ConnectionEditor.tsx
  • packages/client/src/components/ui/DraftNumberInput.tsx
  • packages/client/src/components/ui/GenerationParametersEditor.tsx
  • packages/client/src/components/chat/ChatSettingsDrawer.tsx
  • packages/server/src/services/storage/chat-presets.storage.ts
  • packages/shared/src/constants/chat-preset.ts

Audit provenance

Found by a multi-agent re-review of the connection/preset subsystem (editors UI + send-pipeline) against the merged staging tree (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.

AI-drafted from a static read; validation/test-plan boxes intentionally left UNCHECKED for a human to verify before close.

Originally created by @kolacheee on GitHub (Jun 21, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2773 Originally assigned to: @SpicyMarinara on GitHub. ## Summary Client-side number/URL inputs lack validation matching the server schema (a bad value blocks the entire save with a generic error), the ParamInput display can desync from the saved value, and the chat-settings-preset selector has reset/reconcile gaps including a presetChoices clobber. ## Sub-bug 1: Max Context allows 0 (new-bug) **(a)** The Max Context DraftNumberInput is `min={0}`; committing 0 yields maxContext:0 in the PATCH, which the server `z.number().int().min(1)` rejects -> 400 -> the WHOLE connection save aborts (name/key/model/params lost) with a generic 'Save failed' and no field-level hint. **(c)** ConnectionEditor.tsx:1556-1565/389/416-441; DraftNumberInput.tsx:53-71; connection.schema.ts:29. Kind: new-bug. ## Sub-bug 2: Base URL / Embedding URL no validation (new-bug) **(a)** Bare host:port / scheme-less URLs (common for local models, e.g. `192.168.1.5:8080`) fail the server `.url()` and block the whole save with a generic banner and no field highlight. (Note: `localhost:11434/v1` actually passes Zod, contrary to the original example.) **(c)** ConnectionEditor.tsx:1086-1101/1875-1883/387/395; connection.schema.ts:25/36. Kind: new-bug. ## Sub-bug 3: ParamInput stale display (new-bug) **(a)** On out-of-range/empty entry, ParamInput.commit only setError — never onChange and never reverts draft to value. The box keeps showing the rejected value while the parent/saved value stays the old one, so the display lies about what will be saved (no corruption). **(c)** GenerationParametersEditor.tsx:516-554. Kind: new-bug (low). ## Sub-bug 4-5: Chat-settings-preset reset/reconcile no-ops (ux/validation) **(a)** When `appliedChatPresetId` is null OR points at a deleted preset, `selectedChatPreset` falls back to the Default preset, so the dropdown shows 'Default' but `handleSelectPreset`'s `id === selectedChatPreset?.id` guard makes selecting Default a no-op — the chat can't be reset and a dangling dead id is never cleared. **(c)** ChatSettingsDrawer.tsx:2149-2156/2401-2404; chat-presets.storage.ts:261-309. Kind: new-bug (medium). ## Sub-bug 6: presetChoices clobber on chat-preset apply (data-loss/missed-instance) **(a)** `snapshotCurrentPresetSettings` captures the whole metadata incl. `presetChoices` (per-chat variable answers, keyed by variableName). presetChoices is NOT in CHAT_PRESET_EXCLUDED_METADATA_KEYS, so it's stored in the chat-settings preset and, on apply, overwrites the target chat's own choices (it's not in the preserved set) -> wrong/garbage variable values injected at serialization. The sibling per-chat `agentVariables` IS excluded, showing presetChoices was simply missed. **(c)** ChatSettingsDrawer.tsx:2393-2399/2411-2459; chat-presets.storage.ts:88/277-298; chat-preset.ts:45-112. Kind: missed-instance (medium). ## Suggested Fix - Max Context input `min={1}` (or clamp <1 in payload); add field-level validation surfacing. - Validate Base/Embedding URL client-side (accept empty or parseable URL; optionally auto-prefix http://); show field-level error. - ParamInput: on invalid, revert draft to String(value) or clamp+commit. - Distinguish 'explicitly applied' from 'Default fallback' in handleSelectPreset; allow the Default selection to perform a real reset and clear a dangling appliedChatPresetId. - Add `presetChoices` to CHAT_PRESET_EXCLUDED_METADATA_KEYS. ## Template - [ ] Max Context / URL inputs validated client-side with field-level errors - [ ] ParamInput display matches saved value - [ ] Selecting Default resets a customized/dangling chat - [ ] presetChoices excluded from chat-settings presets - [ ] `pnpm check` passes --- ### Affected files - `packages/client/src/components/connections/ConnectionEditor.tsx` - `packages/client/src/components/ui/DraftNumberInput.tsx` - `packages/client/src/components/ui/GenerationParametersEditor.tsx` - `packages/client/src/components/chat/ChatSettingsDrawer.tsx` - `packages/server/src/services/storage/chat-presets.storage.ts` - `packages/shared/src/constants/chat-preset.ts` ### Audit provenance Found by a multi-agent re-review of the connection/preset subsystem (editors UI + send-pipeline) against the merged `staging` tree (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**. > AI-drafted from a static read; validation/test-plan boxes intentionally left UNCHECKED for a human to verify before close.
Author
Owner

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

Fixed in PR #2747. Verified the findings against the current branch and addressed the still-valid parts: Max Context now clamps to at least 1, Base URL and Embedding Endpoint URL validate/normalize bare local endpoints before save, ParamInput reverts rejected drafts to the saved value, chat-settings preset selection distinguishes custom/missing state so Default can reset, and presetChoices is excluded from chat-settings preset snapshots. Full pnpm validation is intentionally deferred until the remaining open issue is addressed.

<!-- gh-comment-id:4763429068 --> @SpicyMarinara commented on GitHub (Jun 21, 2026): Fixed in PR #2747. Verified the findings against the current branch and addressed the still-valid parts: Max Context now clamps to at least 1, Base URL and Embedding Endpoint URL validate/normalize bare local endpoints before save, ParamInput reverts rejected drafts to the saved value, chat-settings preset selection distinguishes custom/missing state so Default can reset, and presetChoices is excluded from chat-settings preset snapshots. Full pnpm validation is intentionally deferred until the remaining open issue is addressed.
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#1410
No description provided.