{"record":{"id":"3d16160a53a3c362","repo":"jackwener/OpenCLI","slug":"instagram-note-content-cannot-be-empty","errorCode":null,"errorMessage":"Instagram note content cannot be empty.","messagePattern":"Instagram note content cannot be empty\\.","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/instagram/note.js","lineNumber":20,"sourceCode":"import { cli, Strategy } from '@jackwener/opencli/registry';\nconst INSTAGRAM_INBOX_URL = 'https://www.instagram.com/direct/inbox/';\nconst INSTAGRAM_NOTE_DOC_ID = '25155183657506484';\nconst INSTAGRAM_NOTE_MUTATION_NAME = 'usePolarisCreateInboxTrayItemSubmitMutation';\nconst INSTAGRAM_NOTE_ROOT_FIELD = 'xdt_create_inbox_tray_item';\nfunction requirePage(page) {\n    if (!page)\n        throw new CommandExecutionError('Browser session required for instagram note');\n    return page;\n}\nfunction validateInstagramNoteArgs(kwargs) {\n    if (kwargs.content === undefined) {\n        throw new ArgumentError('Argument \"content\" is required.', 'Provide a note text, for example: opencli instagram note \"hello\"');\n    }\n}\nfunction normalizeInstagramNoteContent(kwargs) {\n    const content = String(kwargs.content ?? '').trim();\n    if (!content) {\n        throw new ArgumentError('Instagram note content cannot be empty.', 'Provide a non-empty note text, for example: opencli instagram note \"hello\"');\n    }\n    if (Array.from(content).length > 60) {\n        throw new ArgumentError('Instagram note content must be 60 characters or fewer.', 'Shorten the note text and try again.');\n    }\n    return content;\n}\nfunction buildNoteSuccessResult(noteId) {\n    return [{\n            status: '✅ Posted',\n            detail: 'Instagram note published successfully',\n            noteId,\n        }];\n}\nfunction buildPublishInstagramNoteJs(content) {\n    return `\n    (async () => {\n      const input = ${JSON.stringify({ content })};\n      const html = document.documentElement?.outerHTML || '';","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/instagram/note.js#L2-L38","documentation":"After the required-arg check, normalizeInstagramNoteContent coerces content to a string and trims it. If the result is empty (only whitespace, empty string, or null-ish coerced), the ArgumentError 'Instagram note content cannot be empty' is thrown because Instagram rejects blank notes.","triggerScenarios":"Calling with content: '' , content: '   ', or content: null — String(kwargs.content ?? '').trim() yields '' so the !content branch fires.","commonSituations":"Shell passing an empty quoted string (''); reading the note text from an env var or file that is empty; whitespace-only paste; template variable that interpolated to nothing.","solutions":["Supply non-empty note text: opencli instagram note \"hello\"","Trim/validate the source (env var, file) before passing it","Escape the content properly so the shell does not strip it","Add a pre-call check: if (!kwargs.content?.trim()) throw new Error('note text required')"],"exampleFix":"// before\nconst note = process.env.NOTE_TEXT; // '' in CI\nawait instagramNote(ctx, { content: note });\n// after\nconst note = (process.env.NOTE_TEXT ?? '').trim();\nif (!note) throw new Error('NOTE_TEXT is empty; set it before posting');\nawait instagramNote(ctx, { content: note });","handlingStrategy":"validation","validationCode":"const text = (kwargs.content ?? '').trim();\nif (!text) throw new Error('Note text is empty; provide non-empty content.');","typeGuard":"function isNonEmptyContent(kwargs) {\n  return typeof kwargs?.content === 'string' && kwargs.content.trim().length > 0;\n}","tryCatchPattern":"try {\n  await instagramNote(ctx, { content: noteText });\n} catch (e) {\n  if (e.message.includes('cannot be empty')) {\n    console.error('Note text was empty after trimming; check its source (env/file).');\n  } else throw e;\n}","preventionTips":["Trim and check env/file-sourced note text before passing","Reject whitespace-only input early in your script","Quote shell args so values aren't stripped","Default to a visible placeholder when the source is empty"],"tags":["argument-validation","cli","empty-input"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}