[GH-ISSUE #3708] [Issue]: Bug: character.update silently blanks omitted fields (first_mes, mes_example, etc.) #2002

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

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

Originally assigned to: @SpicyMarinara on GitHub.

Summary

Imported from the Discord thread "Bug: character.update silently blanks omitted fields (first_mes, mes_example, etc.)".

Expected behavior

Not provided in the Discord context.

Actual behavior

See the Discord context transcript below.

Steps to reproduce

  1. Not provided in the Discord context.

Environment

  • Marinara Engine version: Not provided
  • Install type: Not provided
  • OS + version: Not provided
  • Browser or app shell: Not provided

Logs, screenshots, or video

See any attachment links and screenshots in the context below.

Additional context

This issue was created automatically from Discord support context.

Discord thread: Bug: character.update silently blanks omitted fields (first_mes, mes_example, etc.)
Discord thread link: https://discord.com/channels/1417099416812392641/1527401556260163635
Requested by: Marinara (marinara_spaghetti, Discord ID 169561011928432653)

Discord thread transcript (1 message)
[2026-07-16T19:48:28.761Z] Shades: Platform: Win 11
Version: v3.2.2
Build: 8ab3f71

Repro:
Have a character with a greeting (first_mes) and example dialogues (mes_example).
Update the character via the character.update app-data action with a patch touching only one unrelated field, e.g. {"personality": "..."}.
Read the card back — first_mes and mes_example are now empty strings.

Root cause (packages/server/src/services/mari-db/mari-db.service.ts):
normalizeCharacterActionData() (~line 749) does out.first_mes = out.first_mes ?? out.firstMes ?? out.firstMessage ?? out.greeting; — when no alias is present in the patch, this explicitly assigns undefined, creating a first_mes: undefined key. Same pattern hits mes_example, creator_notes, system_prompt, post_history_instructions, character_version, and alternate_greetings.
deepMerge() (~line 521) treats undefined values as deletions: if (value === undefined) { delete out[key]; continue; } — so those fields get stripped from the merged card.
buildMinimalCharacterData() then backfills them with empty defaults ("" / []).

Suggested fix: in normalizeCharacterActionData, only assign an alias-coalesced value when at least one alias is actually defined, e.g.:
tsif (out.first_mes === undefined) {
  const v = out.firstMes ?? out.firstMessage ?? out.greeting;
  if (v !== undefined) out.first_mes = v;
}
(or delete the key when the coalesce resolves to undefined).

Impact: any partial character update from Professor Mari or other app-data callers destroys greetings and example dialogues without warning.
[Discord message: https://discord.com/channels/1417099416812392641/1527401556260163635/1527401556260163635]

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 @SpicyMarinara on GitHub (Jul 16, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3708 Originally assigned to: @SpicyMarinara on GitHub. ## Summary Imported from the Discord thread "Bug: character.update silently blanks omitted fields (first_mes, mes_example, etc.)". ## Expected behavior Not provided in the Discord context. ## Actual behavior See the Discord context transcript below. ## Steps to reproduce 1. Not provided in the Discord context. ## Environment - Marinara Engine version: Not provided - Install type: Not provided - OS + version: Not provided - Browser or app shell: Not provided ## Logs, screenshots, or video See any attachment links and screenshots in the context below. ## Additional context This issue was created automatically from Discord support context. Discord thread: Bug: character.update silently blanks omitted fields (first_mes, mes_example, etc.) Discord thread link: https://discord.com/channels/1417099416812392641/1527401556260163635 Requested by: Marinara (marinara_spaghetti, Discord ID 169561011928432653) <details> <summary>Discord thread transcript (1 message)</summary> ```text [2026-07-16T19:48:28.761Z] Shades: Platform: Win 11 Version: v3.2.2 Build: 8ab3f71 Repro: Have a character with a greeting (first_mes) and example dialogues (mes_example). Update the character via the character.update app-data action with a patch touching only one unrelated field, e.g. {"personality": "..."}. Read the card back — first_mes and mes_example are now empty strings. Root cause (packages/server/src/services/mari-db/mari-db.service.ts): normalizeCharacterActionData() (~line 749) does out.first_mes = out.first_mes ?? out.firstMes ?? out.firstMessage ?? out.greeting; — when no alias is present in the patch, this explicitly assigns undefined, creating a first_mes: undefined key. Same pattern hits mes_example, creator_notes, system_prompt, post_history_instructions, character_version, and alternate_greetings. deepMerge() (~line 521) treats undefined values as deletions: if (value === undefined) { delete out[key]; continue; } — so those fields get stripped from the merged card. buildMinimalCharacterData() then backfills them with empty defaults ("" / []). Suggested fix: in normalizeCharacterActionData, only assign an alias-coalesced value when at least one alias is actually defined, e.g.: tsif (out.first_mes === undefined) { const v = out.firstMes ?? out.firstMessage ?? out.greeting; if (v !== undefined) out.first_mes = v; } (or delete the key when the coalesce resolves to undefined). Impact: any partial character update from Professor Mari or other app-data callers destroys greetings and example dialogues without warning. [Discord message: https://discord.com/channels/1417099416812392641/1527401556260163635/1527401556260163635] ``` </details> ## 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:44:30 +07:00
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#2002
No description provided.