jackwener/OpenCLI · error · ArgumentError
Argument "content" is required.
Error message
Argument "content" is required.
What it means
validateInstagramNoteArgs enforces that the kwargs passed to instagram note include content. When kwargs.content === undefined the ArgumentError is thrown with a usage hint. This is an input-contract check performed before any browser or network work.
Source
Thrown at clis/instagram/note.js:14
import { ArgumentError, CommandExecutionError } from '@jackwener/opencli/errors';
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,
}];View on GitHub (pinned to 49907e53dc)
Solutions
- Pass the note text as an argument: opencli instagram note "hello"
- Quote the content so shells keep empty/whitespace values intact
- In programmatic use, set kwargs.content before calling
- Check your arg-parser setup isn't discarding empty-string arguments
Example fix
// before
const kwargs = {}; // content missing
await instagramNote(ctx, kwargs);
// after
const kwargs = { content: 'hello world' };
await instagramNote(ctx, kwargs); Defensive patterns
Strategy: validation
Validate before calling
if (typeof kwargs.content !== 'string') {
throw new TypeError('content is required: opencli instagram note "hello"');
} Type guard
function hasContent(kwargs) {
return kwargs != null && typeof kwargs.content === 'string';
} Try / catch
try {
await instagramNote(ctx, kwargs);
} catch (e) {
if (e.message.includes('content" is required')) {
console.error('Usage: opencli instagram note "<text>"');
} else throw e;
} Prevention
- Quote note text in shell invocations
- Validate argv length before invoking the command
- Check arg-parser config doesn't drop empty strings
- In scripts, assert kwargs.content exists before the call
When it happens
Trigger: Invoking the note command with no positional text (e.g. 'opencli instagram note') or programmatically calling with kwargs lacking the content key.
Common situations: Copy-pasting the command but omitting the quoted note text; shell quoting swallowing an empty string argument; building kwargs dynamically and forgetting the content field; CLI arg parser dropping empty strings.
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
- facebook marketplace-inbox --limit must be a positive intege
- Jike search query cannot be empty
- --limit must be a positive integer
- --limit must be an integer between 1 and ${MAX_LIMIT}
- ${label} is required
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/69e45cf25ff65b80.
Report an issue: GitHub.