affaan-m/ECC · error
is too long (maximum characters).
Error message
${label} is too long (maximum ${maxChars} characters). What it means
asNonEmptyString enforces a maximum length (default 10,000 chars; 64 for labels/enums/slugs) on validated strings to keep memory-vault records small and safe. Values that are valid strings but exceed the cap are rejected with the label and the limit in the message.
Solutions
- Truncate the input to maxChars before validation (mind surrogate pairs).
- Use a field sized for the content (e.g. a body/description field with a higher cap) instead of a short label field.
- Summarize or compress large content before saving to the vault.
- Reduce the content in the source document or split it across records.
Example fix
// before asNonEmptyString(longArticle, 'title') // throws if > 10000 chars // after asNonEmptyString(longArticle.slice(0, 10000), 'title')
Defensive patterns
Strategy: validation
Validate before calling
const MAX = 10000
if (typeof value === 'string' && value.trim().length > MAX) {
value = Array.from(value.trim()).slice(0, MAX).join('')
} Type guard
function isWithinLength(v, max = 10000) {
return typeof v === 'string' && v.trim().length <= max
}
if (!isWithinLength(input.content)) throw new RangeError('content exceeds 10000 characters') Try / catch
try {
asNonEmptyString(value, 'content')
} catch (err) {
if (err.message.includes('is too long')) {
const max = Number(err.message.match(/maximum (\d+)/)?.[1] ?? 10000)
value = value.trim().slice(0, max)
} else throw err
} Prevention
- Truncate long user input at the boundary before saving.
- Use the appropriate field for large content (body vs title).
- Truncate by code points (Array.from) to avoid splitting surrogate pairs.
- Cap textarea maxlength / CLI input length in the UI.
When it happens
Trigger: Calling asNonEmptyString with a string whose trimmed length exceeds maxChars — e.g. pasting a multi-KB document into a title field, or a 65+ char label/slug via validateEnum/validateSlug.
Common situations: Storing an entire article body where only a summary belongs; unbounded user input from a textarea; generated slugs not truncated; test fixtures with very long strings.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- memory body is too large
- 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/09b553013bc588a1.
Report an issue: GitHub.
Appendix: source
Thrown at scripts/lib/memory-vault-format.js:83
const allowedWhitespace = allowBodyWhitespace
&& (codePoint === 0x09 || codePoint === 0x0a || codePoint === 0x0d);
const isControl = (codePoint <= 0x1f && !allowedWhitespace)
|| (codePoint >= 0x7f && codePoint <= 0x9f);
const isBidirectionalFormatting = (
(codePoint >= 0x202a && codePoint <= 0x202e)
|| (codePoint >= 0x2066 && codePoint <= 0x2069)
);
return isControl || isBidirectionalFormatting;
});
}
function asNonEmptyString(value, label, maxChars = 10_000) {
if (typeof value !== 'string' || value.trim().length === 0) {
throw new Error(`${label} must be a non-empty string.`);
}
const normalized = value.trim();
if (normalized.length > maxChars) {
throw new Error(`${label} is too long (maximum ${maxChars} characters).`);
}
if (hasUnsafeControlCharacters(normalized)) {
throw new Error(`${label} must not contain control or bidirectional formatting characters.`);
}
return normalized;
}
function validateEnum(value, allowed, label) {
const normalized = asNonEmptyString(value, label, 64);
if (!allowed.includes(normalized)) {
throw new Error(`${label} must be one of: ${allowed.join(', ')}.`);
}
return normalized;
}
function validateSlug(value, label) {
const normalized = asNonEmptyString(value, label, 64);
if (!SLUG_PATTERN.test(normalized)) {View on GitHub (pinned to 8321021c54)