mirror of
https://github.com/garrytan/gstack.git
synced 2026-06-17 07:10:12 +02:00
fix(memory-ingest): strip NUL bytes from transcript body before put
Postgres rejects 0x00 in UTF-8 text columns. Some Claude Code transcripts contain NUL inside user-pasted content or tool output, and surfacing those as `internal_error: invalid byte sequence` from the brain is unhelpful when we can sanitize at write time. Uses the \x00 escape form in the regex literal so the source survives editors that strip control chars and remains reviewable in diffs. Contributed by @billy-armstrong (#1411). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -819,6 +819,11 @@ function gbrainPutPage(page: PageRecord): { ok: boolean; error?: string } {
|
||||
body,
|
||||
].join("\n");
|
||||
}
|
||||
// Strip NUL bytes — Postgres rejects 0x00 in UTF-8 text columns. Some Claude
|
||||
// Code transcripts contain NUL inside user-pasted content or tool output, and
|
||||
// surfacing those as `internal_error: invalid byte sequence` from the brain
|
||||
// is unhelpful when we can sanitize at write time.
|
||||
body = body.replace(/\x00/g, "");
|
||||
try {
|
||||
execFileSync("gbrain", ["put", page.slug], {
|
||||
input: body,
|
||||
|
||||
Reference in New Issue
Block a user