[GH-ISSUE #2275] 09-CHAT-ERROR-chat-message-validation rejects legacy invalid payloads #1112

Closed
opened 2026-10-21 05:26:54 +07:00 by bsakaguchi · 0 comments
Owner

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

Originally assigned to: @Promansis on GitHub.

Summary

09-CHAT-ERROR-chat-message-validation: refactor chat metadata and bulk message action validation accepts cases that legacy rejected or normalized. Invalid Discord webhook URLs can be persisted through chat metadata, invalid inactiveCharacterIds are not clamped to active chat characters at the storage boundary, and empty/filtered bulk message delete or hidden payloads can resolve as successful no-ops.

Expected behavior

Legacy behavior should be preserved for the Target 9 validation surface:

  • Chat metadata updates reject invalid Discord webhook URLs with a user-visible validation error.
  • inactiveCharacterIds must be an array of strings and should be normalized to IDs that belong to the chat.
  • Bulk delete and bulk hidden payloads should reject empty/invalid message ID lists instead of reporting success.
  • Missing chat/message, stale edit, invalid swipe index, and last-swipe delete errors should continue to surface precise failures.

Actual behavior

Refactor has UI affordances and several negative controls, but the metadata write path is generic and does not enforce the legacy chat-specific validation. The settings UI shows an invalid Discord URL warning while still calling patchChatMetadata, which merges arbitrary metadata and sends it through generic storage_update. Bulk delete and bulk hidden hooks filter IDs down to a unique array, then allow an empty list to flow through as a no-op success.

Steps to reproduce

  1. On refactor, update a chat with metadata containing discordWebhookUrl: "not-a-discord-webhook" through storageApi.patchChatMetadata or the Discord Mirror setting.
  2. Observe the generic metadata patch path persists the value instead of rejecting it like legacy PATCH /:id/metadata.
  3. Invoke bulk delete or bulk hidden with an empty/blank-only messageIds array.
  4. Observe the refactor path can return success/no-op instead of the legacy validation error.

Impact area

  • App shell, navigation, startup, or providers
  • Catalog resources
  • Chat mode
  • Roleplay mode
  • Game mode
  • Shared mode UI
  • Runtime systems: generation, world-state, visuals, tracker, or haptics
  • Professor Mari or shell tools
  • React-free engine behavior, contracts, agents, or capability ports
  • Shared API wrapper or remote runtime routing
  • Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime
  • Docs, contributor workflow, or templates

Environment

  • Branch or commit: refactor (refactor@37585ab9 from #2268 scan context)
  • Run mode: Tauri desktop / web shell / remote runtime validation surface
  • OS + version: not runtime-tested
  • Node + pnpm versions: not runtime-tested
  • Rust version, if relevant: not runtime-tested
  • Remote Runtime URL configured? not relevant
  • Provider, model, or integration, if relevant: Discord webhook metadata validation

Logs, screenshots, or video

Static proof from Batch 8 parityscan:

  • Legacy validates Discord URL and clamps inactiveCharacterIds: main:packages/server/src/routes/chats.routes.ts:475, main:packages/server/src/routes/chats.routes.ts:483.
  • Legacy rejects empty bulk delete/hidden payloads: main:packages/server/src/routes/chats.routes.ts:1097, main:packages/server/src/routes/chats.routes.ts:1140.
  • Refactor settings still calls metadata mutation while only showing a client-side warning: src/features/modes/shared/chat-ui/components/ChatSettingsDrawer.tsx:5605, src/features/modes/shared/chat-ui/components/ChatSettingsDrawer.tsx:5614.
  • Refactor metadata patch path is generic merge/update with no chat metadata validation: src/shared/api/storage-api.ts:199, src/shared/api/storage-api.ts:433, src-tauri/src/commands/storage/commands/entities.rs:474.
  • Refactor bulk delete/bulk hidden hooks filter blank IDs but allow an empty unique list to continue: src/features/catalog/chats/hooks/use-chats.ts:581, src/features/catalog/chats/hooks/use-chats.ts:717.
  • Refactor Rust bulk delete accepts missing/empty IDs as {"deleted": 0}: src-tauri/src/commands/storage/chats.rs:616.

Regression notes

Worked in legacy main according to #2268 Target 9 inventory and Batch 8 static trace. This issue tracks parity gap for 09-CHAT-ERROR-chat-message-validation and links back to #2268.

Acceptance criteria:

  • 09-CHAT-ERROR-chat-message-validation rejects invalid Discord webhook URLs through every durable chat metadata write path.
  • inactiveCharacterIds metadata writes reject non-array/non-string payloads and normalize to valid chat character IDs.
  • Empty or blank-only bulk delete payloads reject with a precise user-facing error.
  • Empty or blank-only bulk hidden payloads reject with a precise user-facing error.
  • Existing precise errors for missing chat/message, stale edit, invalid swipe index, missing swipe, and deleting the last swipe remain intact.
  • Embedded and hostable remote-runtime paths behave the same where the commands are exposed.

Additional context

Parent parity tracker: #2268.

Batch 8 also inspected 09-CHAT-UI-message-action-controls. No issue is filed for that surface because the user-visible action controls were present in the direct UI owners inspected.

Template check

Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Promansis on GitHub (Jun 5, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2275 Originally assigned to: @Promansis on GitHub. ## Summary `09-CHAT-ERROR-chat-message-validation`: refactor chat metadata and bulk message action validation accepts cases that legacy rejected or normalized. Invalid Discord webhook URLs can be persisted through chat metadata, invalid `inactiveCharacterIds` are not clamped to active chat characters at the storage boundary, and empty/filtered bulk message delete or hidden payloads can resolve as successful no-ops. ## Expected behavior Legacy behavior should be preserved for the Target 9 validation surface: - Chat metadata updates reject invalid Discord webhook URLs with a user-visible validation error. - `inactiveCharacterIds` must be an array of strings and should be normalized to IDs that belong to the chat. - Bulk delete and bulk hidden payloads should reject empty/invalid message ID lists instead of reporting success. - Missing chat/message, stale edit, invalid swipe index, and last-swipe delete errors should continue to surface precise failures. ## Actual behavior Refactor has UI affordances and several negative controls, but the metadata write path is generic and does not enforce the legacy chat-specific validation. The settings UI shows an invalid Discord URL warning while still calling `patchChatMetadata`, which merges arbitrary metadata and sends it through generic `storage_update`. Bulk delete and bulk hidden hooks filter IDs down to a unique array, then allow an empty list to flow through as a no-op success. ## Steps to reproduce 1. On `refactor`, update a chat with metadata containing `discordWebhookUrl: "not-a-discord-webhook"` through `storageApi.patchChatMetadata` or the Discord Mirror setting. 2. Observe the generic metadata patch path persists the value instead of rejecting it like legacy `PATCH /:id/metadata`. 3. Invoke bulk delete or bulk hidden with an empty/blank-only `messageIds` array. 4. Observe the refactor path can return success/no-op instead of the legacy validation error. ## Impact area - [ ] App shell, navigation, startup, or providers - [ ] Catalog resources - [x] Chat mode - [x] Roleplay mode - [x] Game mode - [x] Shared mode UI - [ ] Runtime systems: generation, world-state, visuals, tracker, or haptics - [ ] Professor Mari or shell tools - [ ] React-free engine behavior, contracts, agents, or capability ports - [x] Shared API wrapper or remote runtime routing - [x] Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime - [ ] Docs, contributor workflow, or templates ## Environment - Branch or commit: `refactor` (`refactor@37585ab9` from #2268 scan context) - Run mode: Tauri desktop / web shell / remote runtime validation surface - OS + version: not runtime-tested - Node + pnpm versions: not runtime-tested - Rust version, if relevant: not runtime-tested - Remote Runtime URL configured? not relevant - Provider, model, or integration, if relevant: Discord webhook metadata validation ## Logs, screenshots, or video Static proof from Batch 8 parityscan: - Legacy validates Discord URL and clamps `inactiveCharacterIds`: `main:packages/server/src/routes/chats.routes.ts:475`, `main:packages/server/src/routes/chats.routes.ts:483`. - Legacy rejects empty bulk delete/hidden payloads: `main:packages/server/src/routes/chats.routes.ts:1097`, `main:packages/server/src/routes/chats.routes.ts:1140`. - Refactor settings still calls metadata mutation while only showing a client-side warning: `src/features/modes/shared/chat-ui/components/ChatSettingsDrawer.tsx:5605`, `src/features/modes/shared/chat-ui/components/ChatSettingsDrawer.tsx:5614`. - Refactor metadata patch path is generic merge/update with no chat metadata validation: `src/shared/api/storage-api.ts:199`, `src/shared/api/storage-api.ts:433`, `src-tauri/src/commands/storage/commands/entities.rs:474`. - Refactor bulk delete/bulk hidden hooks filter blank IDs but allow an empty unique list to continue: `src/features/catalog/chats/hooks/use-chats.ts:581`, `src/features/catalog/chats/hooks/use-chats.ts:717`. - Refactor Rust bulk delete accepts missing/empty IDs as `{"deleted": 0}`: `src-tauri/src/commands/storage/chats.rs:616`. ## Regression notes Worked in legacy `main` according to #2268 Target 9 inventory and Batch 8 static trace. This issue tracks parity gap for `09-CHAT-ERROR-chat-message-validation` and links back to #2268. Acceptance criteria: - [ ] `09-CHAT-ERROR-chat-message-validation` rejects invalid Discord webhook URLs through every durable chat metadata write path. - [ ] `inactiveCharacterIds` metadata writes reject non-array/non-string payloads and normalize to valid chat character IDs. - [ ] Empty or blank-only bulk delete payloads reject with a precise user-facing error. - [ ] Empty or blank-only bulk hidden payloads reject with a precise user-facing error. - [ ] Existing precise errors for missing chat/message, stale edit, invalid swipe index, missing swipe, and deleting the last swipe remain intact. - [ ] Embedded and hostable remote-runtime paths behave the same where the commands are exposed. ## Additional context Parent parity tracker: #2268. Batch 8 also inspected `09-CHAT-UI-message-action-controls`. No issue is filed for that surface because the user-visible action controls were present in the direct UI owners inspected. ## Template check Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:26:54 +07:00
  • closed this issue
  • added the
    bug
    label
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#1112
No description provided.