{"record":{"id":"cd410758680ad53f","repo":"jackwener/OpenCLI","slug":"title-is-required-cd4107","errorCode":null,"errorMessage":"--title is required","messagePattern":"--title is required","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/notebooklm/write-note.js","lineNumber":15,"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}","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/notebooklm/write-note.js#L1-L33","documentation":"parseNoteTitle validates the --title option for the write-note command: it stringifies and trims the value, and throws ArgumentError when nothing remains. This guarantees every note created in NotebookLM has a non-empty title before any browser automation runs.","triggerScenarios":"Calling write-note without --title, with --title \"\" or whitespace-only, or passing undefined/null for the title parameter.","commonSituations":"Forgetting the flag on the command line, a script variable being empty because an upstream command produced no output, or quoting mistakes yielding an empty argument.","solutions":["Pass a non-empty --title value, e.g. --title \"Meeting notes\".","Quote titles containing spaces so the shell does not split or drop them.","In scripts, check the title variable is non-empty before invoking write-note.","Fix the upstream command/pipeline that produced an empty title."],"exampleFix":"// before\nawait writeNote({ title: process.env.NOTE_TITLE, content });\n\n// after\nconst title = (process.env.NOTE_TITLE || '').trim();\nif (!title) throw new Error('NOTE_TITLE must be set to a non-empty value');\nawait writeNote({ title, content });","handlingStrategy":"validation","validationCode":"const title = String(rawTitle ?? '').trim();\nif (!title) throw new Error('--title is required');","typeGuard":"const hasTitle = (v) => typeof v === 'string' && v.trim().length > 0;","tryCatchPattern":"try {\n  await writeNote({ title, content });\n} catch (e) {\n  if (String(e.message).includes('--title is required')) {\n    console.error('Usage: write-note --title \"My note\" --content \"...\"');\n    process.exit(2);\n  }\n  throw e;\n}","preventionTips":["Always quote --title values in shell scripts.","Check upstream variables for emptiness before invoking write-note.","Default missing titles to a timestamped placeholder in wrappers.","Validate required CLI flags at script start."],"tags":["argument-validation","cli","missing-argument","notebooklm"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}