{"record":{"id":"729ea8e5a347d086","repo":"jackwener/OpenCLI","slug":"content-must-not-be-empty","errorCode":null,"errorMessage":"--content must not be empty","messagePattern":"--content must not be empty","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/notebooklm/add-source.js","lineNumber":84,"sourceCode":"export function parseSourceUrl(value) {\n    const url = String(value ?? '').trim();\n    if (!url) return '';\n    let parsed;\n    try {\n        parsed = new URL(url);\n    } catch {\n        throw new ArgumentError(`Invalid source URL: \"${url}\"`, 'URL must be a valid http:// or https:// URL.');\n    }\n    if ((parsed.protocol !== 'http:' && parsed.protocol !== 'https:') || !parsed.hostname) {\n        throw new ArgumentError(`Invalid source URL: \"${url}\"`, 'URL must start with http:// or https://.');\n    }\n    return parsed.toString();\n}\n\nexport function parseSourceText(value) {\n    if (value === undefined || value === null) return null;\n    const text = String(value);\n    if (!text.trim()) throw new ArgumentError('--content must not be empty');\n    if (text.length > MAX_TEXT_SOURCE_BYTES) {\n        throw new ArgumentError(`--content exceeds ${MAX_TEXT_SOURCE_BYTES} bytes; split into smaller sources or upload as a file.`);\n    }\n    return text;\n}\n\nexport function parseSourceTitle(value, fallback) {\n    const title = String(value ?? '').trim();\n    return title || fallback;\n}\n\nexport function buildAddSourceFromUrlArgs(projectId, url) {\n    return [[[null, null, [url]]], projectId];\n}\n\nexport function buildAddSourceFromTextArgs(projectId, title, content) {\n    return [[[null, [title, content], null, 2]], projectId];\n}","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/notebooklm/add-source.js#L66-L102","documentation":"parseSourceText throws this ArgumentError when --content is provided but is whitespace-only after conversion to a string. Since the value is not undefined/null (which would mean 'no text source'), an empty string is treated as a user mistake rather than an omitted option, so it fails fast before any upload is attempted.","triggerScenarios":"Calling add-source with --content '' or --content '   '; a variable holding the text being empty because an earlier step produced no output; passing --content without a value so the shell supplies an empty string.","commonSituations":"Scripting the CLI where a text-extraction step returned an empty file/stdout; quoting mistakes producing an empty argument; CI pipelines where an env var like $NOTES was unset, expanding to nothing.","solutions":["Provide non-empty text with --content.","If you meant to omit the text source entirely, drop the --content flag instead of passing an empty value.","Fix the upstream step that produced empty text (check the file/stdout it reads from).","Guard in your script: only pass --content when text.trim() is non-empty."],"exampleFix":"// before\naddSource({ content: notes.trim() }); // notes was empty\n// after\nif (notes.trim()) addSource({ content: notes });\nelse addSource({ url: fallbackUrl });","handlingStrategy":"validation","validationCode":"const text = typeof content === 'string' ? content : '';\nif (text !== '' && !text.trim()) throw new Error('Refusing to pass empty --content; omit the flag or supply real text');","typeGuard":"function isNonEmptyText(v) { return typeof v === 'string' && v.trim().length > 0; }","tryCatchPattern":"try {\n  await addSource({ content });\n} catch (e) {\n  if (e instanceof ArgumentError && e.message === '--content must not be empty') {\n    console.error('The upstream text source produced empty output; check the extraction step.');\n  } else throw e;\n}","preventionTips":["Only include --content when the text trims to non-empty.","Assert upstream extraction steps produce output before invoking the CLI.","Watch for unset env vars expanding to empty strings in scripts.","Omit the flag entirely rather than passing an empty value."],"tags":["argument-validation","notebooklm","empty-input"],"backgroundTag":"empty-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}