affaan-m/ECC · error · Error

memory body must contain non-whitespace context.

Error message

memory body must contain non-whitespace context.

What it means

normalizeBody trims the input and throws if nothing remains — a body consisting solely of whitespace (spaces, tabs, newlines) is rejected. Every memory must carry actual non-whitespace content to be worth storing in the vault.

Solutions

  1. Ensure the body has real content before calling; guard with if (body.trim()) before saving.
  2. Fix the generator/template so the body placeholder is populated.
  3. Skip creating the memory entirely when there is no content rather than writing an empty stub.
  4. If a sanitization step emptied the body, treat that as an error upstream and do not persist.

Example fix

// before
saveMemory({ title: 'notes', body: placeholder /* '' */ })
// after
const body = placeholder.trim();
if (body) saveMemory({ title: 'notes', body });
Defensive patterns

Strategy: validation

Validate before calling

const trimmed = typeof body === 'string' ? body.trim() : '';
if (!trimmed) throw new Error('refusing to save memory with empty body');

Type guard

const hasContent = (v) => typeof v === 'string' && v.trim().length > 0;

Try / catch

try { normalizeMemory(mem); } catch (e) { if (e.message.includes('non-whitespace context')) { console.warn('skipping empty memory', mem.title); return null; } throw e; }

Prevention

When it happens

Trigger: Calling normalizeMemory with body '', ' ', '\n\t', or a string of only whitespace characters; also produced when an upstream strip of control characters left an originally non-empty string blank.

Common situations: A generator that created a memory file but never filled the body; a template with an unfilled placeholder that collapsed to whitespace; an aggressive sanitizer removing all content; conditional writes where the body variable was initialized to '' and never set.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/1e7703a81d0ee130. Report an issue: GitHub.

Appendix: source

Thrown at scripts/lib/memory-vault-format.js:153

    !ISO_TIMESTAMP_PATTERN.test(normalized)
    || Number.isNaN(parsed.getTime())
    || parsed.toISOString() !== normalized
  ) {
    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) {

View on GitHub (pinned to 8321021c54)