jackwener/OpenCLI · error · ArgumentError

Instagram note content cannot be empty.

Error message

Instagram note content cannot be empty.

What it means

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.

Source

Thrown at clis/instagram/note.js:20

import { cli, Strategy } from '@jackwener/opencli/registry';
const INSTAGRAM_INBOX_URL = 'https://www.instagram.com/direct/inbox/';
const INSTAGRAM_NOTE_DOC_ID = '25155183657506484';
const INSTAGRAM_NOTE_MUTATION_NAME = 'usePolarisCreateInboxTrayItemSubmitMutation';
const INSTAGRAM_NOTE_ROOT_FIELD = 'xdt_create_inbox_tray_item';
function requirePage(page) {
    if (!page)
        throw new CommandExecutionError('Browser session required for instagram note');
    return page;
}
function validateInstagramNoteArgs(kwargs) {
    if (kwargs.content === undefined) {
        throw new ArgumentError('Argument "content" is required.', 'Provide a note text, for example: opencli instagram note "hello"');
    }
}
function normalizeInstagramNoteContent(kwargs) {
    const content = String(kwargs.content ?? '').trim();
    if (!content) {
        throw new ArgumentError('Instagram note content cannot be empty.', 'Provide a non-empty note text, for example: opencli instagram note "hello"');
    }
    if (Array.from(content).length > 60) {
        throw new ArgumentError('Instagram note content must be 60 characters or fewer.', 'Shorten the note text and try again.');
    }
    return content;
}
function buildNoteSuccessResult(noteId) {
    return [{
            status: '✅ Posted',
            detail: 'Instagram note published successfully',
            noteId,
        }];
}
function buildPublishInstagramNoteJs(content) {
    return `
    (async () => {
      const input = ${JSON.stringify({ content })};
      const html = document.documentElement?.outerHTML || '';

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Supply non-empty note text: opencli instagram note "hello"
  2. Trim/validate the source (env var, file) before passing it
  3. Escape the content properly so the shell does not strip it
  4. Add a pre-call check: if (!kwargs.content?.trim()) throw new Error('note text required')

Example fix

// before
const note = process.env.NOTE_TEXT; // '' in CI
await instagramNote(ctx, { content: note });
// after
const note = (process.env.NOTE_TEXT ?? '').trim();
if (!note) throw new Error('NOTE_TEXT is empty; set it before posting');
await instagramNote(ctx, { content: note });
Defensive patterns

Strategy: validation

Validate before calling

const text = (kwargs.content ?? '').trim();
if (!text) throw new Error('Note text is empty; provide non-empty content.');

Type guard

function isNonEmptyContent(kwargs) {
  return typeof kwargs?.content === 'string' && kwargs.content.trim().length > 0;
}

Try / catch

try {
  await instagramNote(ctx, { content: noteText });
} catch (e) {
  if (e.message.includes('cannot be empty')) {
    console.error('Note text was empty after trimming; check its source (env/file).');
  } else throw e;
}

Prevention

When it happens

Trigger: Calling with content: '' , content: ' ', or content: null — String(kwargs.content ?? '').trim() yields '' so the !content branch fires.

Common situations: 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.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/3d16160a53a3c362. Report an issue: GitHub.