basic-memory icon indicating copy to clipboard operation
basic-memory copied to clipboard

Return and surface a readable domain error when `structuredContent` is null

Open pharaoh1st opened this issue 2 weeks ago • 0 comments

Observed behavior

An exact duplicate write_note(..., overwrite=False) through the MCP client returned only a client-side schema error:

[{"expected":"record","code":"invalid_type","path":["structuredContent"],
  "message":"Invalid input: expected record, received null"}]

The same call through the direct MCP transport returned the readable server refusal:

# Error: Note already exists ... "<title>" already exists
(permalink: <project>/<path>/<slug>). write_note does not overwrite by default.

The refusal itself is correct: no duplicate note was created, and the existing note kept its original content and attempt marker. The defect is the error surface. Because the tool advertises an output schema, the client rejects structuredContent: null before the caller can read the domain message or the collision permalink.

Expected behavior

  1. Basic Memory: on a domain refusal, return isError: true with a structured error record that preserves the message and the permalink (or exact identifier), instead of text plus null structured content.
  2. MCP client / gateway: when isError is true and structuredContent is null, surface the text content (and any _meta) instead of failing output-schema validation.

Either fix alone reduces the defect. Both together remove it.

Why it matters

An operator who sees only the opaque schema error cannot tell whether the note exists, where it is, or whether a retry is safe. The natural next action is a blind retry, which risks a duplicate or an overwrite. The readable message already exists on the server; it is lost in the client validation step.

Repro notes

No secrets or customer data are required. Reproduce by calling write_note twice with the same title and overwrite=False through an MCP client that validates the tool output schema.

pharaoh1st avatar Nov 11 '26 23:11 pharaoh1st