[GH-ISSUE #3857] [Issue]: Fresh chat tag filters miss tags because API returns raw metadata strings #2084

Closed
opened 2026-10-21 05:45:14 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @Xelvanis on GitHub (Jul 20, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3857

Originally assigned to: @SpicyMarinara on GitHub.

Summary

After a fresh load, chat tag filtering and search can omit existing tags because GET /api/chats returns file-storage rows whose metadata and characterIds fields are JSON strings, while the shared Chat contract and client query treat them as parsed values.

The same storage/transport mismatch exists for message extra, character data, and several persona fields. This leaves components maintaining local parsers and makes the shared response types unreliable.

Expected behavior

HTTP responses typed as shared Chat, Message, Character, or Persona values should match those contracts: JSON-backed fields should arrive as parsed arrays/objects and string-backed booleans as booleans. Storage row representations should remain internal.

Actual behavior

  • chats.storage.list() returns raw file-table rows and the /chats route forwards them.
  • useChats() casts res.json() directly to Chat[].
  • ChatSidebar.getChatTags() only reads object metadata, so fresh string metadata yields no tags.
  • Metadata mutations later normalize the affected cached chat, making tags appear inconsistently after editing.
  • Message, character, and persona routes expose similar raw string fields despite parsed shared types.
  • Persona create/update requests are manually cast and do not have shared schemas.

Steps to reproduce

  1. Use a chat whose metadata contains at least one tag.
  2. Reload the application so the chat list is populated from GET /api/chats.
  3. Open the sidebar tag controls or search for that tag; the tag may be absent until a metadata mutation normalizes the cached chat.

Environment

  • Marinara Engine version: 2.3.3 staging
  • Install type: source
  • OS + version: Environment-independent code path; verified from a Windows source checkout
  • Browser or app shell: Not live-reproduced; confirmed by static server/client trace

Logs, screenshots, or video

No logs or screenshots. Static trace:

  • packages/server/src/services/storage/chats.storage.ts returns raw chat rows.
  • packages/server/src/routes/chats.routes.ts forwards them.
  • packages/client/src/hooks/use-chats.ts types the response as Chat[] without normalization.
  • packages/client/src/components/layout/ChatSidebar.tsx only extracts tags from object metadata.

Additional context

This is a broader transport-boundary issue rather than only a sidebar bug. A durable direction would be to add canonical row-to-domain mappers at the server response boundary for chats, messages, characters, and personas, keeping file-storage row types internal. Shared raw transport DTOs are only preferable if storage-shaped HTTP payloads are intentionally supported.

Persona create/update schemas should be handled as a related but separable validation change.

Related closed issue: #2801 fixed one cache-corruption symptom caused by the same raw-string metadata boundary, but the list response remains storage-shaped. The broader storage audit in #2028 did not resolve this contract mismatch.

No data loss was confirmed. Current impact is inconsistent UI behavior, misleading shared contracts, and duplicated client parsing.

Template check

Please uncheck (untick) 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 @Xelvanis on GitHub (Jul 20, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3857 Originally assigned to: @SpicyMarinara on GitHub. ## Summary After a fresh load, chat tag filtering and search can omit existing tags because `GET /api/chats` returns file-storage rows whose `metadata` and `characterIds` fields are JSON strings, while the shared `Chat` contract and client query treat them as parsed values. The same storage/transport mismatch exists for message `extra`, character `data`, and several persona fields. This leaves components maintaining local parsers and makes the shared response types unreliable. ## Expected behavior HTTP responses typed as shared `Chat`, `Message`, `Character`, or `Persona` values should match those contracts: JSON-backed fields should arrive as parsed arrays/objects and string-backed booleans as booleans. Storage row representations should remain internal. ## Actual behavior - `chats.storage.list()` returns raw file-table rows and the `/chats` route forwards them. - `useChats()` casts `res.json()` directly to `Chat[]`. - `ChatSidebar.getChatTags()` only reads object metadata, so fresh string metadata yields no tags. - Metadata mutations later normalize the affected cached chat, making tags appear inconsistently after editing. - Message, character, and persona routes expose similar raw string fields despite parsed shared types. - Persona create/update requests are manually cast and do not have shared schemas. ## Steps to reproduce 1. Use a chat whose metadata contains at least one tag. 2. Reload the application so the chat list is populated from `GET /api/chats`. 3. Open the sidebar tag controls or search for that tag; the tag may be absent until a metadata mutation normalizes the cached chat. ## Environment - Marinara Engine version: 2.3.3 staging - Install type: source - OS + version: Environment-independent code path; verified from a Windows source checkout - Browser or app shell: Not live-reproduced; confirmed by static server/client trace ## Logs, screenshots, or video No logs or screenshots. Static trace: - `packages/server/src/services/storage/chats.storage.ts` returns raw chat rows. - `packages/server/src/routes/chats.routes.ts` forwards them. - `packages/client/src/hooks/use-chats.ts` types the response as `Chat[]` without normalization. - `packages/client/src/components/layout/ChatSidebar.tsx` only extracts tags from object metadata. ## Additional context This is a broader transport-boundary issue rather than only a sidebar bug. A durable direction would be to add canonical row-to-domain mappers at the server response boundary for chats, messages, characters, and personas, keeping file-storage row types internal. Shared raw transport DTOs are only preferable if storage-shaped HTTP payloads are intentionally supported. Persona create/update schemas should be handled as a related but separable validation change. Related closed issue: #2801 fixed one cache-corruption symptom caused by the same raw-string metadata boundary, but the list response remains storage-shaped. The broader storage audit in #2028 did not resolve this contract mismatch. No data loss was confirmed. Current impact is inconsistent UI behavior, misleading shared contracts, and duplicated client parsing. ## Template check Please **uncheck (untick)** 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:45:14 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Jul 20, 2026):

SpicyMarinara is taking this issue in the current assigned-issue sweep. I’m tracing the reported boundary, adding focused regression coverage, and will link the draft PR here as soon as the proof commit is pushed.

<!-- gh-comment-id:5022367640 --> @SpicyMarinara commented on GitHub (Jul 20, 2026): SpicyMarinara is taking this issue in the current assigned-issue sweep. I’m tracing the reported boundary, adding focused regression coverage, and will link the draft PR here as soon as the proof commit is pushed.
Author
Owner

@SpicyMarinara commented on GitHub (Jul 20, 2026):

Implementation is now tracked in draft PR #3862 against staging.

<!-- gh-comment-id:5022407507 --> @SpicyMarinara commented on GitHub (Jul 20, 2026): Implementation is now tracked in draft PR #3862 against `staging`.
Author
Owner

@SpicyMarinara commented on GitHub (Jul 20, 2026):

Addressed in #3862 and merged to staging as ca6d0c15be.

<!-- gh-comment-id:5022913811 --> @SpicyMarinara commented on GitHub (Jul 20, 2026): Addressed in #3862 and merged to staging as ca6d0c15bee712686203483621028050ed0239a9.
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#2084
No description provided.