memory.list tag filter errors at the DB layer ("malformed array literal") #1

Closed
opened 2026-06-12 18:30:15 +00:00 by jknapp · 0 comments
Owner

Summary

tools/callmemory.list with a tags argument fails with a Postgres error. memory.list without tags works; memory.write and memory.search with tags work. Only memory.list's tag filter is broken.

Repro

HTTP POST /api/mcp, cli-v1 bearer, project-scoped.

One tagmalformed array literal: "kind.scratchpad"

{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"memory.list","arguments":{"scope":"project","project":"hosting-assistant-ops","tags":["kind.scratchpad"],"limit":5}}}

Two tagscannot cast type record to text[]

{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"memory.list","arguments":{"scope":"project","project":"hosting-assistant-ops","tags":["kind.scratchpad","smoke.deploy"],"limit":5}}}

No tags → works (returns items).
Same tags via memory.search → works (but search appears to boost by tags, not require them, so it's not a substitute for list-by-tags).

Impact

Any client listing notes filtered by tags fails. Worked around downstream by fetching unfiltered and filtering client-side (require-all-tags), but that caps at the server's 200-item limit — a server fix is preferable.

Likely cause

The tags filter in the list query builds a malformed text[] literal / casts a record to text[]. Compare with the working memory.search tag handling. Probable fix: bind tags as a proper array param and use containment (tags @> $1::text[]) or = ANY(...).

Doc nit (not a bug)

Tag writes reject anything outside [A-Za-z0-9._-] (e.g. :) with a zod regex error only at write time. Documenting the allowed tag charset in the tool schema would save trial-and-error.

Filed by Claude on behalf of @jknapp during the hosting-assistant integration.

## Summary `tools/call` → `memory.list` with a `tags` argument fails with a Postgres error. `memory.list` **without** tags works; `memory.write` and `memory.search` **with** tags work. Only `memory.list`'s tag filter is broken. ## Repro HTTP `POST /api/mcp`, `cli-v1` bearer, project-scoped. **One tag** → `malformed array literal: "kind.scratchpad"` ```json {"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"memory.list","arguments":{"scope":"project","project":"hosting-assistant-ops","tags":["kind.scratchpad"],"limit":5}}} ``` **Two tags** → `cannot cast type record to text[]` ```json {"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"memory.list","arguments":{"scope":"project","project":"hosting-assistant-ops","tags":["kind.scratchpad","smoke.deploy"],"limit":5}}} ``` **No tags** → works (returns items). **Same tags via `memory.search`** → works (but `search` appears to *boost* by tags, not *require* them, so it's not a substitute for list-by-tags). ## Impact Any client listing notes filtered by tags fails. Worked around downstream by fetching unfiltered and filtering client-side (require-all-tags), but that caps at the server's 200-item limit — a server fix is preferable. ## Likely cause The `tags` filter in the list query builds a malformed `text[]` literal / casts a record to `text[]`. Compare with the working `memory.search` tag handling. Probable fix: bind tags as a proper array param and use containment (`tags @> $1::text[]`) or `= ANY(...)`. ## Doc nit (not a bug) Tag writes reject anything outside `[A-Za-z0-9._-]` (e.g. `:`) with a zod regex error only at write time. Documenting the allowed tag charset in the tool schema would save trial-and-error. _Filed by Claude on behalf of @jknapp during the hosting-assistant integration._
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: cybercove-labs/shared-memory#1