affaan-m/ECC · error · Error
${label} is too long (maximum ${maxChars} characters).
Error message
${label} is too long (maximum ${maxChars} characters). What it means
Thrown by asNonEmptyString() when the trimmed string exceeds maxChars (default 10000; titles use 200, enums 64, ids 132). The bound is set per field to keep memory documents small and indexable.
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 01e15490f0)
Solutions
- Trim or summarize the value to fit the documented per-field limit.
- Move long content into the body field (which uses a much larger byte limit) rather than the title.
- Check the label in the error to identify the field and its cap.
Example fix
// before asNonEmptyString(longParagraph, 'title', 200); // after asNonEmptyString(longParagraph.slice(0, 180).trim() + '...', 'title', 200);
Defensive patterns
Strategy: validation
Validate before calling
function fitsMaxChars(value, maxChars) {
return typeof value === 'string' && value.trim().length <= maxChars;
}
if (!fitsMaxChars(title, 200)) {
throw new Error(`title exceeds 200 characters (got ${title.trim().length}).`);
} Type guard
function isWithinLength(value, maxChars) {
return typeof value === 'string' && value.trim().length <= maxChars;
} Try / catch
try {
result = asNonEmptyString(value, label, maxChars);
} catch (e) {
if (/is too long/.test(e.message)) {
result = asNonEmptyString(value.slice(0, maxChars - 1).trim() + '…', label, maxChars);
} else throw e;
} Prevention
- Enforce maxlength on form inputs matching the documented per-field limits.
- For long content, use the body field rather than the title.
- Run a pre-flight trim/length check in your submission pipeline.
When it happens
Trigger: Submitting a title longer than 200 characters, a slug longer than 64, or a body/memory id beyond its specific cap.
Common situations: Pasting a long paragraph into a title field; auto-generated content that concatenates many values; a slug derived from an unbounded source.
Related errors
- ${label} must be a non-empty string.
- ${label} must not contain control or bidirectional formattin
- ${label} must be one of: ${allowed.join(', ')}.
- ${label} must be a lowercase letters/numbers slug.
- memory id must match mem_<lowercase-id> and cannot contain a
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/09b553013bc588a1.
Report an issue: GitHub.