{"record":{"id":"09b553013bc588a1","repo":"affaan-m/ECC","slug":"label-is-too-long-maximum-maxchars-characte","errorCode":null,"errorMessage":"${label} is too long (maximum ${maxChars} characters).","messagePattern":"(.+?) is too long \\(maximum (.+?) characters\\)\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/memory-vault-format.js","lineNumber":83,"sourceCode":"    const allowedWhitespace = allowBodyWhitespace\n      && (codePoint === 0x09 || codePoint === 0x0a || codePoint === 0x0d);\n    const isControl = (codePoint <= 0x1f && !allowedWhitespace)\n      || (codePoint >= 0x7f && codePoint <= 0x9f);\n    const isBidirectionalFormatting = (\n      (codePoint >= 0x202a && codePoint <= 0x202e)\n      || (codePoint >= 0x2066 && codePoint <= 0x2069)\n    );\n    return isControl || isBidirectionalFormatting;\n  });\n}\n\nfunction asNonEmptyString(value, label, maxChars = 10_000) {\n  if (typeof value !== 'string' || value.trim().length === 0) {\n    throw new Error(`${label} must be a non-empty string.`);\n  }\n  const normalized = value.trim();\n  if (normalized.length > maxChars) {\n    throw new Error(`${label} is too long (maximum ${maxChars} characters).`);\n  }\n  if (hasUnsafeControlCharacters(normalized)) {\n    throw new Error(`${label} must not contain control or bidirectional formatting characters.`);\n  }\n  return normalized;\n}\n\nfunction validateEnum(value, allowed, label) {\n  const normalized = asNonEmptyString(value, label, 64);\n  if (!allowed.includes(normalized)) {\n    throw new Error(`${label} must be one of: ${allowed.join(', ')}.`);\n  }\n  return normalized;\n}\n\nfunction validateSlug(value, label) {\n  const normalized = asNonEmptyString(value, label, 64);\n  if (!SLUG_PATTERN.test(normalized)) {","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/lib/memory-vault-format.js#L65-L101","documentation":"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.","triggerScenarios":"Submitting a title longer than 200 characters, a slug longer than 64, or a body/memory id beyond its specific cap.","commonSituations":"Pasting a long paragraph into a title field; auto-generated content that concatenates many values; a slug derived from an unbounded source.","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."],"exampleFix":"// before\nasNonEmptyString(longParagraph, 'title', 200);\n// after\nasNonEmptyString(longParagraph.slice(0, 180).trim() + '...', 'title', 200);","handlingStrategy":"validation","validationCode":"function fitsMaxChars(value, maxChars) {\n  return typeof value === 'string' && value.trim().length <= maxChars;\n}\nif (!fitsMaxChars(title, 200)) {\n  throw new Error(`title exceeds 200 characters (got ${title.trim().length}).`);\n}","typeGuard":"function isWithinLength(value, maxChars) {\n  return typeof value === 'string' && value.trim().length <= maxChars;\n}","tryCatchPattern":"try {\n  result = asNonEmptyString(value, label, maxChars);\n} catch (e) {\n  if (/is too long/.test(e.message)) {\n    result = asNonEmptyString(value.slice(0, maxChars - 1).trim() + '…', label, maxChars);\n  } else throw e;\n}","preventionTips":["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."],"tags":["memory-vault","validation","string","length"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}