{"record":{"id":"8dea0ff527047649","repo":"jackwener/OpenCLI","slug":"createlist-returned-mode-mode-expected-expec","errorCode":null,"errorMessage":"CreateList returned mode ${mode}, expected ${expectedMode}.","messagePattern":"CreateList returned mode (.+?), expected (.+?)\\.","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"critical","filePath":"clis/twitter/list-create.js","lineNumber":78,"sourceCode":"        throw new CommandExecutionError(`CreateList returned no list payload. Body: ${String(result.bodyText || '').slice(0, 300)}`);\n    }\n    const id = String(list.id_str || list.id || '');\n    if (!/^\\d+$/.test(id)) {\n        throw new CommandExecutionError('CreateList returned a list payload without a numeric list id.');\n    }\n    if (typeof list.name !== 'string' || !list.name.trim()) {\n        throw new CommandExecutionError('CreateList returned a list payload without a list name.');\n    }\n    if (list.name.trim() !== expectedName) {\n        throw new CommandExecutionError(`CreateList returned name ${JSON.stringify(list.name)}, expected ${JSON.stringify(expectedName)}.`);\n    }\n    const modeValue = typeof list.mode === 'string' ? list.mode : '';\n    if (!modeValue) {\n        throw new CommandExecutionError('CreateList returned a list payload without list mode.');\n    }\n    const mode = /private/i.test(modeValue) ? 'private' : 'public';\n    if (mode !== expectedMode) {\n        throw new CommandExecutionError(`CreateList returned mode ${mode}, expected ${expectedMode}.`);\n    }\n    return { createdList: list, listId: id, listMode: mode };\n}\n\nexport function buildListCreateRow({ result, name, description, mode }) {\n    const { createdList, listId, listMode } = requireCreateListResult(result, name, mode);\n    return {\n        id: listId,\n        name: createdList.name,\n        description: typeof createdList.description === 'string' ? createdList.description : description,\n        mode: listMode,\n        status: 'success',\n    };\n}\n\ncli({\n    site: 'twitter',\n    name: 'list-create',","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/twitter/list-create.js#L60-L96","documentation":"After normalizing mode (any value matching /private/i becomes 'private', otherwise 'public'), requireCreateListResult compares it to the mode the user requested. It throws when the created list's mode differs from expectedMode — e.g. you asked for private but Twitter created a public list. This is a safety check so private lists are never silently created as public.","triggerScenarios":"CreateList response mode normalizes to a value different from the requested mode string ('public'/'private') — wrong query variables (mode key typo), API ignoring the mode param, or expectedMode computed incorrectly from --private flag.","commonSituations":"Sending `mode` in the wrong spot of the GraphQL variables so Twitter defaults to public; parsing bug turning --private false into expected private; older API version ignoring the mode field.","solutions":["Verify the GraphQL variables include isPrivate/mode correctly (CreateList uses `isPrivate: true` for private lists, not mode:\"private\")","Inspect the response payload's mode to confirm what Twitter actually created","Delete the wrongly-created list and recreate with corrected variables","Re-check how the CLI derives expectedMode from --private/--mode flags"],"exampleFix":"// before\nvariables: JSON.stringify({ name, description, mode: expectedMode })\n// after\nvariables: JSON.stringify({ name, description, isPrivate: expectedMode === 'private' })","handlingStrategy":"validation","validationCode":"if (expectedMode !== 'public' && expectedMode !== 'private') throw new Error(`bad expectedMode: ${expectedMode}`);\nconst isPrivate = expectedMode === 'private'; // pass isPrivate in CreateList variables","typeGuard":"function modeMatches(list, expectedMode) {\n  const m = /private/i.test(String(list?.mode || '')) ? 'private' : 'public';\n  return m === expectedMode;\n}","tryCatchPattern":"try {\n  const row = buildListCreateRow({ result, name, description, mode });\n} catch (e) {\n  if (/returned mode/.test(e.message)) console.error('Mode mismatch — deleting wrongly-created list and aborting:', e.message);\n  else throw e;\n}","preventionTips":["Send isPrivate:true (not mode:\"private\") in CreateList variables for private lists","Verify expectedMode derivation from CLI flags","Never ignore a mode mismatch on private lists — it leaks data"],"tags":["privacy","mode-mismatch","twitter-graphql"],"backgroundTag":"schema-validation-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}