{"record":{"id":"e26ea06d29cce2d5","repo":"ruvnet/ruflo","slug":"value-exceeds-maximum-size-of-max-value-size-by","errorCode":null,"errorMessage":"Value exceeds maximum size of ${MAX_VALUE_SIZE} bytes","messagePattern":"Value exceeds maximum size of (.+?) bytes","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/mcp-tools/memory-tools.ts","lineNumber":76,"sourceCode":"}\n\n// D-2: Input bounds for memory parameters\nconst MAX_KEY_LENGTH = 1024;\nconst MAX_VALUE_SIZE = 1024 * 1024; // 1MB\nconst MAX_QUERY_LENGTH = 4096;\n\n// #1425 — single source of truth for the dangerous-character set rejected by\n// validateMemoryInput. Imported by sanitizeMemoryKey so write-side sanitization\n// and read-side rejection can never drift apart (the symmetry bug behind #1884).\nconst DANGEROUS_KEY_CHARS = /[;&|`$(){}[\\]<>!#\\\\\\0]|\\.\\.[/\\\\]/g;\nconst DANGEROUS_KEY_PATTERN = /[;&|`$(){}[\\]<>!#\\\\\\0]|\\.\\.[/\\\\]/;\n\nfunction validateMemoryInput(key?: string, value?: string, query?: string, namespace?: string): void {\n  if (key && key.length > MAX_KEY_LENGTH) {\n    throw new Error(`Key exceeds maximum length of ${MAX_KEY_LENGTH} characters`);\n  }\n  if (value && value.length > MAX_VALUE_SIZE) {\n    throw new Error(`Value exceeds maximum size of ${MAX_VALUE_SIZE} bytes`);\n  }\n  if (query && query.length > MAX_QUERY_LENGTH) {\n    throw new Error(`Query exceeds maximum length of ${MAX_QUERY_LENGTH} characters`);\n  }\n  // Reject path traversal and shell metacharacters in keys/namespaces (#1425)\n  if (key && DANGEROUS_KEY_PATTERN.test(key)) {\n    throw new Error('Key contains disallowed characters');\n  }\n  if (namespace && DANGEROUS_KEY_PATTERN.test(namespace)) {\n    throw new Error('Namespace contains disallowed characters');\n  }\n}\n\n// #1884 — sanitize a key produced from arbitrary input (markdown headings,\n// frontmatter names, file names) so it survives validateMemoryInput on the\n// read/delete path. Replaces every dangerous char with `_`. Truncates to\n// MAX_KEY_LENGTH so the bound check in validateMemoryInput also passes.\n// Keep this in sync with DANGEROUS_KEY_PATTERN — they share DANGEROUS_KEY_CHARS.","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/ruvnet/ruflo/blob/6b01dc5a687b26b3e218f796de45ec51f8fa9e8c/v3/@claude-flow/cli/src/mcp-tools/memory-tools.ts#L58-L94","documentation":"Thrown by validateMemoryInput when a memory value exceeds 1 MB (MAX_VALUE_SIZE = 1024*1024). The memory backend persists values to JSON/SQLite; unbounded values would blow up the store and serialisation. The check is a strict length comparison on the value string.","triggerScenarios":"Calling memory store with a value string longer than 1,048,576 characters/bytes. Common with large logs, full file contents, or serialised embeddings.","commonSituations":"Storing an entire log file or stack trace; serialising a large object/array; pasting a base64-encoded binary; an LLM context dump; embedding vectors stored as verbose JSON.","solutions":["Chunk large payloads into multiple keyed entries (e.g. doc-1, doc-2).","Store large blobs externally (filesystem, object storage) and keep only a reference in memory.","Compress or summarise the value before storing.","Pre-check value.length <= 1048576 before calling memory store."],"exampleFix":"// before\nmemory store --key \"log\" --value \"$(cat huge.log)\"\n// after\n// store a reference instead\nmemory store --key \"log\" --value \"{\\\"path\\\":\\\"/data/logs/huge.log\\\"}\"","handlingStrategy":"validation","validationCode":"const MAX_VALUE_SIZE = 1024 * 1024;\nfunction assertValueSize(value) {\n  if (typeof value === 'string' && value.length > MAX_VALUE_SIZE) {\n    throw new Error(`value is ${value.length} bytes; max ${MAX_VALUE_SIZE}. Chunk or externalise.`);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Externalise large blobs and store a reference.","Chunk oversized payloads into sharded keys.","Summarise/compress before storing."],"tags":["memory","validation","input-validation","limits","mcp-tools"],"backgroundTag":null,"analyzedSha":"6b01dc5a687b26b3e218f796de45ec51f8fa9e8c","analyzedAt":"2026-08-12T13:20:50.148Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}