{"record":{"id":"f29e8be3af8abcf4","repo":"jackwener/OpenCLI","slug":"createlist-returned-a-list-payload-without-list-mo","errorCode":null,"errorMessage":"CreateList returned a list payload without list mode.","messagePattern":"CreateList returned a list payload without list mode\\.","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/twitter/list-create.js","lineNumber":74,"sourceCode":"        const errors = result.bodyJson?.errors;\n        if (Array.isArray(errors) && errors.length > 0) {\n            throw new CommandExecutionError(`CreateList failed: ${errors[0].message || JSON.stringify(errors[0])}`);\n        }\n        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}","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/twitter/list-create.js#L56-L92","documentation":"requireCreateListResult requires the CreateList response to include a string `mode` field (public/private). It throws when the payload has no mode or a non-string mode. Mode is required so the CLI can verify the list's privacy setting matches what the user requested.","triggerScenarios":"CreateList GraphQL response contains a list object without `mode` or with mode of a non-string type — schema drift, partial response, or mocked test payload missing mode.","commonSituations":"Twitter updates the CreateList response schema; an API gateway strips fields; unit-test fixtures omit mode.","solutions":["Log the raw response payload to confirm which fields Twitter now returns","Update the parser/queryId+FEATURES to match the current CreateList schema","Retry the command in case of a transient partial response","Add a fallback that re-fetches the list by id to read its mode"],"exampleFix":"// before\nconst modeValue = typeof list.mode === 'string' ? list.mode : '';\n// after\nlet modeValue = typeof list.mode === 'string' ? list.mode : '';\nif (!modeValue && list.customizable !== undefined) modeValue = list.customizable ? 'private' : 'public'; // fallback field","handlingStrategy":"type-guard","validationCode":"if (!result?.data?.create_list || typeof result.data.create_list.mode !== 'string') {\n  throw new Error('CreateList payload missing mode');\n}","typeGuard":"function hasListMode(list) {\n  return !!list && typeof list === 'object' && (list.mode === 'public' || list.mode === 'private');\n}","tryCatchPattern":"try {\n  const row = buildListCreateRow({ result, name, description, mode });\n} catch (e) {\n  if (/without list mode/.test(e.message)) console.error('Response schema drifted; dump payload', JSON.stringify(result));\n  else throw e;\n}","preventionTips":["Assert response shape in tests with a current fixture","Handle schema drift explicitly rather than trusting fields exist","Re-fetch the list by id as a fallback when mode is missing"],"tags":["api-response","validation","twitter-graphql"],"backgroundTag":"schema-validation-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}