{"record":{"id":"e7f9338f3fc00cfb","repo":"jackwener/OpenCLI","slug":"title-must-be-at-most-max-title-len-character","errorCode":null,"errorMessage":"--title must be at most ${MAX_TITLE_LEN} characters (got ${title.length})","messagePattern":"--title must be at most (.+?) characters \\(got (.+?)\\)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/notebooklm/write-note.js","lineNumber":17,"sourceCode":"import { cli, Strategy } from '@jackwener/opencli/registry';\nimport { ArgumentError, CommandExecutionError } from '@jackwener/opencli/errors';\nimport { NOTEBOOKLM_DOMAIN, NOTEBOOKLM_SITE } from './shared.js';\nimport { callNotebooklmRpc } from './rpc.js';\nimport { buildNotebooklmNotebookUrl, ensureNotebooklmHome, parseNotebooklmNotebookTarget, requireNotebooklmExecute, requireNotebooklmSession } from './utils.js';\n\nconst NOTEBOOKLM_CREATE_NOTE_RPC_ID = 'CYK0Xb';\nconst NOTEBOOKLM_MUTATE_NOTE_RPC_ID = 'cYAfTb';\nconst MAX_TITLE_LEN = 200;\nconst MAX_CONTENT_LEN = 1_000_000;\nconst NOTE_UUID_RE = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i;\n\nexport function parseNoteTitle(value) {\n    const title = String(value ?? '').trim();\n    if (!title) throw new ArgumentError('--title is required');\n    if (title.length > MAX_TITLE_LEN) {\n        throw new ArgumentError(`--title must be at most ${MAX_TITLE_LEN} characters (got ${title.length})`);\n    }\n    return title;\n}\n\nexport function parseNoteContent(value) {\n    const content = String(value ?? '');\n    if (!content) throw new ArgumentError('--content is required');\n    if (content.length > MAX_CONTENT_LEN) {\n        throw new ArgumentError(`--content exceeds ${MAX_CONTENT_LEN} characters; split into smaller notes.`);\n    }\n    return content;\n}\n\nexport function buildCreateNoteShellArgs(projectId) {\n    return [projectId, '', [1], null, 'New Note', null, [2]];\n}\n\nexport function buildMutateNoteArgs(projectId, noteId, content, title) {","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/notebooklm/write-note.js#L1-L35","documentation":"parseNoteTitle enforces MAX_TITLE_LEN (200 characters) on the trimmed --title value. Titles longer than the limit are rejected with ArgumentError reporting both the cap and the actual length, keeping note titles within NotebookLM/UI-friendly bounds.","triggerScenarios":"Passing a --title whose trimmed length exceeds 200 characters — e.g. piping a whole sentence/paragraph, a generated summary, or a filename-heavy path as the title.","commonSituations":"Scripts that substitute document content for the title, templated titles with long prefixes, or non-Latin text where users misjudge character counts.","solutions":["Shorten the title to 200 characters or fewer.","Truncate programmatically before calling: title.slice(0, 200).","Move long descriptive text into --content and keep --title a short label.","Validate length in your script before invoking the command to get a friendlier message."],"exampleFix":"// before\nawait writeNote({ title: longSummary, content });\n\n// after\nconst title = longSummary.trim().slice(0, 200);\nawait writeNote({ title, content: longSummary + '\\n\\n' + content });","handlingStrategy":"validation","validationCode":"const MAX_TITLE_LEN = 200;\nif (title.trim().length > MAX_TITLE_LEN) {\n  throw new Error(`--title must be at most ${MAX_TITLE_LEN} characters`);\n}","typeGuard":"const isAcceptableTitle = (v) => typeof v === 'string' && v.trim().length > 0 && v.trim().length <= 200;","tryCatchPattern":"try {\n  await writeNote({ title, content });\n} catch (e) {\n  const m = String(e.message).match(/--title must be at most (\\d+) characters \\(got (\\d+)\\)/);\n  if (m) {\n    console.error(`Shorten the title by ${Number(m[2]) - Number(m[1])} characters.`);\n    process.exit(2);\n  }\n  throw e;\n}","preventionTips":["Truncate titles to 200 characters in wrapper scripts before calling.","Keep long text in --content; use short labels for --title.","Watch character counts for non-Latin scripts.","Add a length assertion in CI/scripts that generate titles."],"tags":["argument-validation","cli","length-limit","notebooklm"],"backgroundTag":"input-length-exceeded","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}