affaan-m/ECC · error · Error
memory body is too large
Error message
memory body is too large (maximum ${MAX_BODY_BYTES} bytes). What it means
normalizeBody measures the trimmed body in UTF-8 bytes and throws when it exceeds MAX_BODY_BYTES (64 KiB). This keeps each memory document within the overall 128 KiB document budget and prevents single memories from ballooning the vault.
Solutions
- Trim the body to the most relevant excerpt before saving (head/tail of logs with an elision marker).
- Split the content into multiple memory documents and link them with the links field.
- Strip binary/base64 blobs and store a reference/path instead of inlining them.
- Check size with Buffer.byteLength(body, 'utf8') > 64 * 1024 before calling, remembering multi-byte characters count more.
Example fix
// before
normalizeMemory({ body: fullBuildLog, ... })
// after
const MAX = 64 * 1024;
const body = Buffer.byteLength(fullBuildLog, 'utf8') > MAX
? fullBuildLog.slice(0, 20000) + '\n...[truncated]...'
: fullBuildLog;
normalizeMemory({ body, ... }) Defensive patterns
Strategy: validation
Validate before calling
const MAX_BODY_BYTES = 64 * 1024; if (Buffer.byteLength(body, 'utf8') > MAX_BODY_BYTES) body = truncateUtf8Safe(body, MAX_BODY_BYTES);
Type guard
const bodyWithinLimit = (v) => typeof v === 'string' && Buffer.byteLength(v, 'utf8') <= 64 * 1024;
Try / catch
try { normalizeMemory(mem); } catch (e) { if (e.message.includes('too large (maximum')) { mem.body = truncate(mem.body); } else throw e; } Prevention
- Measure size with Buffer.byteLength, not string length (multi-byte chars)
- Split large content into multiple linked memories
- Never inline base64/binary blobs in a memory body
- Truncate logs to relevant excerpts with an elision marker before saving
When it happens
Trigger: Calling normalizeMemory with a body whose UTF-8 encoding exceeds 65536 bytes — e.g. a large pasted log, an embedded base64 blob, or content heavy in multi-byte characters where 30k characters can exceed 64 KiB.
Common situations: Dumping an entire build log or stack trace into one memory; embedding base64 images/data URIs in the body; CJK/emoji-heavy text where byte length greatly exceeds character count; concatenating several documents into one memory instead of splitting them.
Understand the failure class
Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.
Related errors
- is too long (maximum characters).
- application config exceeds local size limit
- candidate configuration exceeds 1 MiB
- has too many values (maximum ).
- must be a lowercase letters/numbers slug.
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/e9acc624a02f25ba.
Report an issue: GitHub.
Appendix: source
Thrown at scripts/lib/memory-vault-format.js:156
) {
throw new Error(`${label} must be an ISO-8601 timestamp.`);
}
return normalized;
}
function normalizeBody(value) {
if (typeof value !== 'string') {
throw new Error('memory body must be a string.');
}
if (hasUnsafeControlCharacters(value, true)) {
throw new Error('memory body must not contain unsafe control or bidirectional formatting characters.');
}
const normalized = value.trim();
if (normalized.length === 0) {
throw new Error('memory body must contain non-whitespace context.');
}
if (Buffer.byteLength(normalized, 'utf8') > MAX_BODY_BYTES) {
throw new Error(`memory body is too large (maximum ${MAX_BODY_BYTES} bytes).`);
}
return normalized;
}
function normalizeMemory(memory) {
if (!memory || typeof memory !== 'object' || Array.isArray(memory)) {
throw new Error('memory must be an object.');
}
const targetHarnesses = uniqueStrings(memory.targetHarnesses, {
label: 'target harnesses',
limit: MAX_TARGETS,
validator: value => validateSlug(value, 'target harness'),
});
if (targetHarnesses.length === 0) {
throw new Error('target harnesses must contain at least one harness or "all".');
}
View on GitHub (pinned to 8321021c54)