{"record":{"id":"545a15c5054008c7","repo":"NousResearch/hermes-agent","slug":"content-too-large","errorCode":null,"errorMessage":"Content too large","messagePattern":"Content too large","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"apps/desktop/electron/main.ts","lineNumber":11799,"sourceCode":"\n  return { path: dst }\n})\n\n// Write a small UTF-8 text file (e.g. a project's IDEA.md at creation). The path\n// is hardened (resolveRequestedPathForIpc) and the parent must already exist —\n// this never creates directory trees or escapes the allowed roots, and content\n// is size-capped so it can't be abused as a bulk-write primitive.\nipcMain.handle('hermes:fs:writeText', async (_event, filePath, content) => {\n  const raw = String(filePath || '').trim()\n\n  if (!raw) {\n    throw new Error('Invalid path')\n  }\n\n  const text = String(content ?? '')\n\n  if (text.length > 1_000_000) {\n    throw new Error('Content too large')\n  }\n\n  const resolved = resolveRequestedPathForIpc(expandUserPath(raw), { purpose: 'Write text file' })\n\n  if (!directoryExists(path.dirname(resolved))) {\n    throw new Error('Parent directory does not exist')\n  }\n\n  await fs.promises.writeFile(resolved, text, 'utf8')\n\n  return { path: resolved }\n})\n\n// Move a file/folder to the OS trash (recoverable) — the VS Code \"Delete\"\n// default. `shell.trashItem` routes to Finder/Explorer/Files trash per platform.\nipcMain.handle('hermes:fs:trash', async (_event, targetPath) => {\n  const target = String(targetPath || '').trim()\n","sourceCodeStart":11781,"sourceCodeEnd":11817,"githubUrl":"https://github.com/NousResearch/hermes-agent/blob/c896c09c42910c584c4c7d2325b58c14713ea42c/apps/desktop/electron/main.ts#L11781-L11817","documentation":"writeText deliberately caps content at 1,000,000 characters so the IPC cannot be abused as a bulk-write primitive; a longer string throws 'Content too large'. The cap is checked before path resolution, so it fires regardless of whether the target path is valid.","triggerScenarios":"Passing text.length > 1_000_000 to hermes:fs:writeText — e.g. pasting a huge document into an IDEA.md editor, or a bug that serializes an entire project/log into the write payload.","commonSituations":"Users pasting large generated content into a small-file field; code that accidentally passes a full file tree or concatenated logs as 'content'.","solutions":["Reduce the content below 1,000,000 characters — this API is for small metadata files, not bulk data","Move large content to a real file via normal file tools / terminal instead of the writeText IPC","Add a client-side length check with a visible counter before submit"],"exampleFix":"// before\nawait ipc.invoke('hermes:fs:writeText', path, text)\n\n// after\nif (text.length > 1_000_000) throw new Error('Note too large — trim below 1,000,000 chars')\nawait ipc.invoke('hermes:fs:writeText', path, text)","handlingStrategy":"validation","validationCode":"const MAX = 1_000_000\nif ((content ?? '').length > MAX) { notify(`Content exceeds ${MAX} characters`); return }\nawait ipc.invoke('hermes:fs:writeText', filePath, content)","typeGuard":"function withinWriteTextCap(text: string): boolean { return text.length <= 1_000_000 }","tryCatchPattern":"catch (e) { if (e instanceof Error && e.message === 'Content too large') notify('Trim the content below 1,000,000 characters') else throw e }","preventionTips":["Show a live character counter with the 1M limit for editable note fields","Never route logs, dumps, or bulk exports through writeText — use real file writes"],"tags":["validation","filesystem","size-limit","ipc","desktop"],"backgroundTag":null,"analyzedSha":"c896c09c42910c584c4c7d2325b58c14713ea42c","analyzedAt":"2026-08-14T17:18:01.089Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}