mirror of
https://github.com/Pasta-Devs/Marinara-Agents.git
synced 2026-12-03 18:55:07 +07:00
[GH-ISSUE #1542] [Issue]: Long-Term Memory: identity repair, batch imports and preflight still send raw server errors to the client #1512
Labels
No labels
agent: chess
agent: conversation-calls
agent: eightball
agent: haptic
agent: hierarchical-maps
agent: hierarchical-maps
agent: illustrator
agent: poker
agent: rock-paper-scissors
agent: tic-tac-toe
agent: uno
artifacts
bug
bugfix
build
catalog
ci
client
dependencies
docs
documentation
enhancement
feature
fixed-in-staging
in-pr
normal-scope
packages
pull-request
qol
regression
roadmap
scope-risk
server
soup
upstream
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Agents#1512
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Promansis on GitHub (Oct 21, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1542
Originally assigned to: @Promansis on GitHub.
Summary
After the error-message hygiene fix, a route that hits an unexpected error logs it and sends a fallback message instead of the error's own text. Three other paths still send that text to the client, which shows it as is, and a fourth would. The text can hold file paths and library internals:
statusCodeand a stringcode, such as Fastify'sFST_ERR_*errors.isLtmServiceErrorchecks only that shape, so such an error would be treated as one of LTM's own and sent with its message and status. Nothing raises one in a route today, so this one is hardening.Affected package
long-term-memory1.4.72 (upstream/stagingbcaebd07d).S=packages/long-term-memory/src/engine/packages/server/src/services/long-term-memoryC=packages/long-term-memory/src/engine/packages/client/src/features/long-term-memoryExpected behavior
An error LTM did not write for users is logged on the server, and the client gets a message that says what failed and that the details are in the server log. LTM's own service errors, such as a model reply that was cut off, and a cancelled import keep their messages. Error codes, statuses of LTM's own errors and retry flags stay as they are.
Actual behavior
Line numbers are on
upstream/stagingbcaebd07d(refreshed 2026-10-21; first checked on8b72729f1).applyLtmIdentityRepairsrestores the backup (S/identity/identity-repair.ts:150-161). If the restore also fails, it logs only the restore error (:154) and throwsidentity_repair_restore_failedwith the message "Identity repair failed and its backup could not be restored: ${message(error)}" (:155-159). The repair error's text goes to the client and is never logged. The Maintenance settings show it.importPackageInteroplists a source it could not save withcode: "source_write_failed"andmessage: error.message(S/sources/interop.ts:1009-1021). Nothing logs it.failed()(S/extraction/source-processing.ts:453-510) useserror.message(:461) for both the result'serror(:504) and its diagnostic (:507). This covers file and snapshot errors as well as provider errors from the Engine. It does not log.C/sources/SourcesWorkspace.tsx:1380,:2639(result rows) and:1392,:2696("{title}: {message}" for write failures).addBlocker(S/drafts/reconciliation.ts:485-490) useserror.messagefor any error, so a storage failure during the check becomes the blocker text (codepreflight_blocked). Review shows it (C/review/ReviewQueue.tsx:1834). Not logged.isLtmServiceError(S/service-error.ts:12-20) accepts any object with a stringmessage, an integerstatusCodeand a stringcode. After the hygiene fix,routeErrorrelies on it, so a library error of that shape would be sent with its own message and status, without being logged. No known path does this today: Fastify's body-limit and content-type errors are raised before the route handler runs, and the Engine's error handler already replaces a 413's message; the Engine's provider errors carrystatus, notstatusCode; Node, SQLite and fetch errors have nostatusCode. Every LTM service error is an instance ofLtmServiceErroror one of its subclasses.Steps to reproduce
updateNotethrownew Error("EACCES: open '/private/marinara/source_chat_a.json'").POST /api/long-term-memory/import/source-noteswithextract: false.writeFailures[0].error.messageis"EACCES: open '/private/marinara/source_chat_a.json'", and Sources would show that path.The same kind of stub shows the other paths:
getNotesByIdsthrowing duringPOST /drafts/:id/preflight(blocker text),updateNotethrowing after the repair's backup is removed duringPOST /identity-repair/apply(500 with the error appended), and a directrouteErrorcall withObject.assign(new Error("Request body is too large: /private/upload"), { statusCode: 413, code: "FST_ERR_CTP_BODY_TOO_LARGE" })(413 with that message).In normal use: with an invalid API key on the memory model, a batch import with extraction on shows the provider's error text under each source that failed.
Minimal fix
One PR, patch bump. Server only; the client already shows whatever message comes back.
S/identity/identity-repair.ts: in the restore-failure branch, log the repair error too, and say "Identity repair failed and its backup could not be restored. Details are in the server log." Same code and status. Remove the now unusedmessage()helper (:606).S/sources/interop.ts: for an error that is not anLtmServiceError, log it with the source id and say "Failed to write imported source note. Details are in the server log."S/extraction/source-processing.tsfailed(): for an error that is neither anLtmServiceErrornor a cancellation, log it with the stage and source id and say "Failed to extract imported source. Details are in the server log." (or "finalize").failureCodeandretryableFailureare unchanged, so a provider's safe error code and status still decide the code and the retry flag.S/drafts/reconciliation.tsaddBlocker: for an error that is not anLtmServiceError, log it with the draft id and say "Long-term memory preflight failed. Details are in the server log." Link-choice and projection errors keep their messages.S/service-error.ts:isLtmServiceErrorbecomeserror instanceof LtmServiceError. Its other callers already send "Index rebuild failed" for anything else.## Unreleased: "A few more unexpected failures no longer show their raw error text, which could include file paths. In Sources, a source that could not be saved or extracted now says "Failed to write imported source note." or "Failed to extract imported source.", followed by "Details are in the server log."; this includes the model provider rejecting the request during an import. In Review, a change that could not be checked says "Long-term memory preflight failed. Details are in the server log." An identity repair in settings whose backup could not be restored says so without the cause. The full error is written to the server log. Messages written for you, such as a model reply that was cut off, show as before."Not included
Regression proof
tests/long-term-memory-routes.regression.ts:updateNotestub deletes the new backup and throws a private-pathError. Expect 500, the new message,identity_repair_restore_failed, and the error in the logger stub. After therouteErrorcases: a Fastify-shaped error gives the 500 fallback withltm_unexpected_failureand is logged.source_write_failedwith the new message, logged. The existing import whose model throws now expectsextract_failedwith the new message.getNotesByIdsthrows on the check's own reads; expect onepreflight_blockedblocker with the new message, logged.tests/long-term-memory-extraction-reliability.regression.ts: the existing snapshot-failure batch expectsextract_failedwith the new message, andsnapshot unavailablein the logger stub.Environment
staging87d1ccadc)upstream/stagingbcaebd07d)Logs, screenshots, or video
None. The regression cases above show the leaked text with made-up paths.
Additional context
Tracker item OT-6. Follows the raw-error clean-up in #1506.
Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked: