{"record":{"id":"756326da05fbeac8","repo":"jackwener/OpenCLI","slug":"collection-name-cannot-be-empty","errorCode":null,"errorMessage":"Collection name cannot be empty","messagePattern":"Collection name cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"clis/instagram/collection-create.js","lineNumber":22,"sourceCode":"    name: 'collection-create',\n    access: 'write',\n    description: 'Create a new Instagram saved-posts collection (folder)',\n    domain: 'www.instagram.com',\n    args: [\n        {\n            name: 'name',\n            required: true,\n            positional: true,\n            help: 'Name of the collection to create',\n        },\n    ],\n    columns: ['status', 'collectionId', 'collectionName', 'mediaCount'],\n    pipeline: [\n        { navigate: 'https://www.instagram.com' },\n        { evaluate: `(async () => {\n  const name = \\${{ args.name | json }};\n  if (!name || !String(name).trim()) {\n    throw new Error('Collection name cannot be empty');\n  }\n  const trimmed = String(name).trim();\n  const csrf = document.cookie.match(/csrftoken=([^;]+)/)?.[1] || '';\n  if (!csrf) {\n    throw new Error('csrftoken cookie missing - make sure you are logged in to Instagram');\n  }\n  const fd = new FormData();\n  fd.append('name', trimmed);\n  fd.append('module_name', 'collection_create');\n  const res = await fetch('https://www.instagram.com/api/v1/collections/create/', {\n    method: 'POST',\n    credentials: 'include',\n    headers: {\n      'X-IG-App-ID': '936619743392459',\n      'X-CSRFToken': csrf,\n    },\n    body: fd,\n  });","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/instagram/collection-create.js#L4-L40","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nconst name = process.env.COLLECTION_NAME; // may be undefined\nawait run(['instagram', 'collection-create', '--name', name]);\n\n// after\nconst name = (process.env.COLLECTION_NAME || '').trim();\nif (!name) throw new Error('COLLECTION_NAME is required');\nawait run(['instagram', 'collection-create', '--name', name]);","handlingStrategy":"validation","validationCode":"function requireNonEmptyName(name) {\n  const trimmed = String(name ?? '').trim();\n  if (!trimmed) throw new Error('Collection name cannot be empty');\n  return trimmed;\n}\nconst name = requireNonEmptyName(process.env.COLLECTION_NAME);","typeGuard":"function isValidCollectionName(v) {\n  return typeof v === 'string' && v.trim().length > 0;\n}","tryCatchPattern":"try {\n  await createInstagramCollection(name);\n} catch (e) {\n  if (e.message === 'Collection name cannot be empty') {\n    console.error('Provide a --name value, e.g. --name \"Saved Recipes\"');\n    process.exitCode = 2;\n    return;\n  }\n  throw e;\n}","preventionTips":["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"],"tags":["validation","instagram","input-validation","cli-arguments"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}