[PR #7291] [MERGED] fix(mari): accept chat ids that start with a dash #7667

Closed
opened 2026-10-24 04:06:19 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7291
Author: @SpicyMarinara
Created: 10/8/2026
Status: ✅ Merged
Merged: 10/8/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/mari-chat-id-dash


📝 Commits (3)

  • 08dd2b1 fix(mari): accept chat ids that start with a dash
  • 8e6e789 Merge origin/staging into fix/mari-chat-id-dash
  • b36267f Merge origin/staging into fix/mari-chat-id-dash

📊 Changes

3 files changed (+44 additions, -5 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 packages/server/src/services/mari-db/mari-db.service.ts (+8 -5)
📝 scripts/regressions/mari/chat-app-data.regression.ts (+35 -0)

📄 Description

Note

Draft until Mari approves: prepared overnight from the nightly e2e triage.

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #7289

Why this change

  • Professor Mari's structured chat.* app_data actions could not read about 1 chat in 4096. Chat ids are 21-character nanoids, and 1/64² of them start with --. executeChatAction rebuilt the action as CLI argv with the chat id as a bare positional, and parseArgs (packages/server/src/services/mari-db/mari-db.service.ts:849) reads any argument that starts with -- as a flag. The id vanished, so chat.get and chat.messages failed with Usage: mari chats get <id> / Usage: mari chats messages <chat-id> ....
  • The same bridge also broke two other inputs, confirmed locally on staging: chat.search with a query that starts with -- failed with Usage: mari chats search <query>, and chat.list with a characterId that starts with -- read the id as another flag and returned every chat unfiltered.
  • CI evidence: Regression Checks run 37618203499 on staging e0d33c86b (Oct 7), job complete-node-regressions, failed scripts/regressions/mari/chat-app-data.regression.ts:32 (assert.equal(fetched.ok, true) after chat.get) with WARN [mari-db] structured app_data action failed ... "message": "Usage: mari chats get <id>". The fixture chat gets a fresh nanoid each run, so the regression flakes about 1 run in 4096 and passes on rerun.
  • executeChatAction is the only app_data family that re-enters a CLI parser (this.executeChatsCommand(argv, …) is the only action-side call into an execute*Command method). character.*, persona.*, lorebook.*, theme.*, personal_extension.*, preset.*, agent.*, home_widget.* and instruction.* call storage directly, and mari db already handles -- ids (db-hyphen-ids.regression.ts), so nothing else needed the change.

What changed

  • executeChatAction passes flag values as --flag=value and puts positionals (chat id, search query) after the -- end-of-options marker that parseArgs already honours. No change to parseArgs or to the typed mari chats … CLI.
  • scripts/regressions/mari/chat-app-data.regression.ts adds a chat with id --Ew_dash-chat-id and character id --dash-character and checks chat.get, chat.messages, chat.list (character filter) and chat.search. Before the fix it fails on chat.get with the same Usage: mari chats get <id> error as CI; after the fix it passes.
  • CHANGELOG.md [Unreleased] entry.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Agent-run results (not a substitute for the boxes above):

  • pnpm check (impeccable, localization, format, lint, e2e/token-estimation types, build): exit 0 on 08dd2b189.
  • node ./scripts/run-regressions.mjs --filter scripts/regressions/mari/: 10/10 passed (includes chat-app-data and db-hyphen-ids).
  • chat-app-data.regression.ts with the new cases on unpatched staging a8ce0021f: fails at chat.get with Usage: mari chats get <id>, the CI error.
  • mari-workspace-context, mari-permissions-mode, mari-write-readback regressions: passed.
  • Local CodeRabbit (coderabbit review --agent --committed, base a8ce0021f): completed with 0 findings.
  • Not run: Docker/Podman, the browser app, Playwright e2e (server-only change).

Manual verification notes

  • Manually verify in a running Engine that Professor Mari can open a chat whose id starts with --: point the server at a scratch data folder that holds a chat whose id starts with -- (make it with a short script that copies a chat and its messages through the storage API under an id such as --test-chat, as chat-app-data.regression.ts does; editing the files by hand is not enough because message files are named after the chat id), ask Mari to read that chat's recent messages, and confirm she gets them instead of a usage error.
  • Manually verify that Mari still reads an ordinary chat's messages with last, afterPost, tail, limit and offset exactly as before (for example "read the last 5 messages of ").
  • Manually verify that asking Mari to list the chats of a specific character returns only that character's chats.
  • Manually verify that asking Mari to search chats for a phrase still returns the matching chats.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

Only CHANGELOG.md changed; no docs under docs/.

UI evidence (if applicable)

Not applicable: server-side change with no UI.

Summary by CodeRabbit

  • Bug Fixes
    • Chat lookups, message retrieval, chat listings, and text searches now correctly handle chat IDs and search terms that begin with --, rather than treating them as options or returning unrelated chats.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/7291 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/8/2026 **Status:** ✅ Merged **Merged:** 10/8/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/mari-chat-id-dash` --- ### 📝 Commits (3) - [`08dd2b1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/08dd2b1894a2187d1b64291824e2ccfd03b70b88) fix(mari): accept chat ids that start with a dash - [`8e6e789`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8e6e78998ca142cfd15426831fab161f365e2ba6) Merge origin/staging into fix/mari-chat-id-dash - [`b36267f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b36267f28312b38217baaf4ca484f201886e8dec) Merge origin/staging into fix/mari-chat-id-dash ### 📊 Changes **3 files changed** (+44 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `packages/server/src/services/mari-db/mari-db.service.ts` (+8 -5) 📝 `scripts/regressions/mari/chat-app-data.regression.ts` (+35 -0) </details> ### 📄 Description > [!NOTE] > Draft until Mari approves: prepared overnight from the nightly e2e triage. > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Closes #7289 ## Why this change - Professor Mari's structured `chat.*` app_data actions could not read about 1 chat in 4096. Chat ids are 21-character nanoids, and `1/64²` of them start with `--`. `executeChatAction` rebuilt the action as CLI argv with the chat id as a bare positional, and `parseArgs` (`packages/server/src/services/mari-db/mari-db.service.ts:849`) reads any argument that starts with `--` as a flag. The id vanished, so `chat.get` and `chat.messages` failed with `Usage: mari chats get <id>` / `Usage: mari chats messages <chat-id> ...`. - The same bridge also broke two other inputs, confirmed locally on `staging`: `chat.search` with a query that starts with `--` failed with `Usage: mari chats search <query>`, and `chat.list` with a `characterId` that starts with `--` read the id as another flag and returned every chat unfiltered. - CI evidence: Regression Checks run [37618203499](https://github.com/Pasta-Devs/Marinara-Engine/actions/runs/37618203499) on `staging` `e0d33c86b` (Oct 7), job `complete-node-regressions`, failed `scripts/regressions/mari/chat-app-data.regression.ts:32` (`assert.equal(fetched.ok, true)` after `chat.get`) with `WARN [mari-db] structured app_data action failed ... "message": "Usage: mari chats get <id>"`. The fixture chat gets a fresh nanoid each run, so the regression flakes about 1 run in 4096 and passes on rerun. - `executeChatAction` is the only app_data family that re-enters a CLI parser (`this.executeChatsCommand(argv, …)` is the only action-side call into an `execute*Command` method). `character.*`, `persona.*`, `lorebook.*`, `theme.*`, `personal_extension.*`, `preset.*`, `agent.*`, `home_widget.*` and `instruction.*` call storage directly, and `mari db` already handles `--` ids (`db-hyphen-ids.regression.ts`), so nothing else needed the change. ## What changed - `executeChatAction` passes flag values as `--flag=value` and puts positionals (chat id, search query) after the `--` end-of-options marker that `parseArgs` already honours. No change to `parseArgs` or to the typed `mari chats …` CLI. - `scripts/regressions/mari/chat-app-data.regression.ts` adds a chat with id `--Ew_dash-chat-id` and character id `--dash-character` and checks `chat.get`, `chat.messages`, `chat.list` (character filter) and `chat.search`. Before the fix it fails on `chat.get` with the same `Usage: mari chats get <id>` error as CI; after the fix it passes. - `CHANGELOG.md` `[Unreleased]` entry. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` Agent-run results (not a substitute for the boxes above): - `pnpm check` (impeccable, localization, format, lint, e2e/token-estimation types, build): exit 0 on `08dd2b189`. - `node ./scripts/run-regressions.mjs --filter scripts/regressions/mari/`: 10/10 passed (includes `chat-app-data` and `db-hyphen-ids`). - `chat-app-data.regression.ts` with the new cases on unpatched `staging` `a8ce0021f`: fails at `chat.get` with `Usage: mari chats get <id>`, the CI error. - `mari-workspace-context`, `mari-permissions-mode`, `mari-write-readback` regressions: passed. - Local CodeRabbit (`coderabbit review --agent --committed`, base `a8ce0021f`): completed with 0 findings. - Not run: Docker/Podman, the browser app, Playwright e2e (server-only change). ### Manual verification notes - Manually verify in a running Engine that Professor Mari can open a chat whose id starts with `--`: point the server at a scratch data folder that holds a chat whose id starts with `--` (make it with a short script that copies a chat and its messages through the storage API under an id such as `--test-chat`, as `chat-app-data.regression.ts` does; editing the files by hand is not enough because message files are named after the chat id), ask Mari to read that chat's recent messages, and confirm she gets them instead of a usage error. - Manually verify that Mari still reads an ordinary chat's messages with `last`, `afterPost`, `tail`, `limit` and `offset` exactly as before (for example "read the last 5 messages of <chat>"). - Manually verify that asking Mari to list the chats of a specific character returns only that character's chats. - Manually verify that asking Mari to search chats for a phrase still returns the matching chats. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) Only `CHANGELOG.md` changed; no docs under `docs/`. ## UI evidence (if applicable) Not applicable: server-side change with no UI. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Chat lookups, message retrieval, chat listings, and text searches now correctly handle chat IDs and search terms that begin with `--`, rather than treating them as options or returning unrelated chats. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:06:19 +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#7667
No description provided.