{"record":{"id":"07f94ddab3a842e6","repo":"jackwener/OpenCLI","slug":"instagram-note-content-must-be-60-characters-or-fe","errorCode":null,"errorMessage":"Instagram note content must be 60 characters or fewer.","messagePattern":"Instagram note content must be 60 characters or fewer\\.","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/instagram/note.js","lineNumber":23,"sourceCode":"const 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 || '';\n      const scripts = Array.from(document.scripts || [])\n        .map((script) => script.textContent || '')\n        .join('\\\\n');","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/instagram/note.js#L5-L41","documentation":"Instagram notes are limited to 60 characters; normalizeInstagramNoteContent counts characters with Array.from(content).length (code points, so emoji count once) and throws this ArgumentError when the trimmed content exceeds 60. This prevents sending a mutation Instagram would reject.","triggerScenarios":"Content whose Unicode code-point length is 61+ — e.g. a long sentence, or repeated emoji where the developer counted UTF-16 units instead of code points and misestimated length.","commonSituations":"Pasting a tweet-length message; assuming the limit is in bytes or UTF-16 units; scripts generating dynamic note text (timestamps, status) that can exceed 60.","solutions":["Shorten the note to 60 code points or fewer","Pre-truncate in scripts: Array.from(text).slice(0, 60).join('')","Validate length before calling to get a friendlier failure","Avoid heavy emoji usage if measuring with .length (UTF-16) — use Array.from or the Intl.Segmenter for accurate counting"],"exampleFix":"// before\nawait instagramNote(ctx, { content: longStatus }); // may exceed 60\n// after\nconst note = Array.from(longStatus.trim()).slice(0, 60).join('');\nawait instagramNote(ctx, { content: note });","handlingStrategy":"validation","validationCode":"if (Array.from(noteText.trim()).length > 60) {\n  noteText = Array.from(noteText.trim()).slice(0, 60).join('');\n}","typeGuard":"function isWithinNoteLimit(text, max = 60) {\n  return typeof text === 'string' && Array.from(text.trim()).length <= max;\n}","tryCatchPattern":"try {\n  await instagramNote(ctx, { content: noteText });\n} catch (e) {\n  if (e.message.includes('60 characters')) {\n    console.error('Note exceeds 60 code points; shorten or truncate before retrying.');\n  } else throw e;\n}","preventionTips":["Measure length with Array.from (code points), not .length (UTF-16)","Truncate generated/dynamic note text to 60 code points","Add a length assertion in scripts that compose note text","Limit emoji-heavy content, which is easy to miscount"],"tags":["argument-validation","length-limit","instagram","unicode"],"backgroundTag":"input-length-limit-exceeded","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}