jackwener/OpenCLI · error
Collection name cannot be empty
Error message
Collection name cannot be empty
What it means
Validation thrown inside the in-page collection-create pipeline when the provided --name argument is empty, whitespace-only, or otherwise falsy after the template substitution. Instagram requires a non-empty name for a new collection, so the CLI guards this before sending any request. It is a pure input-validation error — no network call has been made yet.
Source
Thrown at clis/instagram/collection-create.js:22
name: 'collection-create',
access: 'write',
description: 'Create a new Instagram saved-posts collection (folder)',
domain: 'www.instagram.com',
args: [
{
name: 'name',
required: true,
positional: true,
help: 'Name of the collection to create',
},
],
columns: ['status', 'collectionId', 'collectionName', 'mediaCount'],
pipeline: [
{ navigate: 'https://www.instagram.com' },
{ evaluate: `(async () => {
const name = \${{ args.name | json }};
if (!name || !String(name).trim()) {
throw new Error('Collection name cannot be empty');
}
const trimmed = String(name).trim();
const csrf = document.cookie.match(/csrftoken=([^;]+)/)?.[1] || '';
if (!csrf) {
throw new Error('csrftoken cookie missing - make sure you are logged in to Instagram');
}
const fd = new FormData();
fd.append('name', trimmed);
fd.append('module_name', 'collection_create');
const res = await fetch('https://www.instagram.com/api/v1/collections/create/', {
method: 'POST',
credentials: 'include',
headers: {
'X-IG-App-ID': '936619743392459',
'X-CSRFToken': csrf,
},
body: fd,
});View on GitHub (pinned to 49907e53dc)
Solutions
- Pass a non-empty name: collection-create --name "My Collection"
- Check the shell variable is actually set: echo "$NAME" before invoking
- Quote arguments containing spaces to avoid shell word-splitting eating them
- Add a pre-check in scripts calling the CLI to fail fast on empty names
Example fix
// before
const name = process.env.COLLECTION_NAME; // may be undefined
await run(['instagram', 'collection-create', '--name', name]);
// after
const name = (process.env.COLLECTION_NAME || '').trim();
if (!name) throw new Error('COLLECTION_NAME is required');
await run(['instagram', 'collection-create', '--name', name]); Defensive patterns
Strategy: validation
Validate before calling
function requireNonEmptyName(name) {
const trimmed = String(name ?? '').trim();
if (!trimmed) throw new Error('Collection name cannot be empty');
return trimmed;
}
const name = requireNonEmptyName(process.env.COLLECTION_NAME); Type guard
function isValidCollectionName(v) {
return typeof v === 'string' && v.trim().length > 0;
} Try / catch
try {
await createInstagramCollection(name);
} catch (e) {
if (e.message === 'Collection name cannot be empty') {
console.error('Provide a --name value, e.g. --name "Saved Recipes"');
process.exitCode = 2;
return;
}
throw e;
} Prevention
- Validate --name is non-empty in wrapper scripts before invoking the CLI
- Quote shell arguments so spaces don't drop parts of the name
- Check that environment variables feeding the name are actually set
- Trim the name before passing it to avoid whitespace-only values
When it happens
Trigger: Running the collection-create command with an empty or missing name argument, e.g. `collection-create ''` or omitting --name so the `args.name | json` substitution yields '' or null.
Common situations: Shell variable holding the name is unset/empty (e.g. $NAME not defined); quoting mistakes causing the name to be dropped; programmatic invocation passing an empty string; copy-paste losing the argument.
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
- INVALID_ARGUMENT
- INVALID_ARGUMENT
- series_id must be a non-empty value
- Invalid Chess.com username "${value}" Usernames are 3-25 cha
- coingecko derivatives limit must be a positive integer
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/756326da05fbeac8.
Report an issue: GitHub.