{"record":{"id":"ddcbfa6ecdc485ee","repo":"jackwener/OpenCLI","slug":"list-listid-not-found-among-your-lists-lists","errorCode":null,"errorMessage":"List ${listId} not found among your lists (${listsBefore.length} lists fetched).","messagePattern":"List (.+?) not found among your lists \\((.+?) lists fetched\\)\\.","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/twitter/list-delete.js","lineNumber":110,"sourceCode":"        }\n\n        await page.goto('https://x.com');\n        await page.wait(3);\n        const cookies = await page.getCookies({ url: 'https://x.com' });\n        const ct0 = cookies.find((c) => c.name === 'ct0')?.value || null;\n        if (!ct0) throw new AuthRequiredError('x.com', 'Not logged into x.com (no ct0 cookie)');\n\n        const headers = JSON.stringify({\n            'Authorization': `Bearer ${decodeURIComponent(TWITTER_BEARER_TOKEN)}`,\n            'X-Csrf-Token': ct0,\n            'X-Twitter-Auth-Type': 'OAuth2Session',\n            'X-Twitter-Active-User': 'yes',\n        });\n\n        const listsBefore = await getManagedLists(page, headers);\n        const targetList = listsBefore.find((list) => list.id === listId);\n        if (!targetList) {\n            throw new CommandExecutionError(`List ${listId} not found among your lists (${listsBefore.length} lists fetched).`);\n        }\n\n        await page.goto(`https://x.com/i/lists/${listId}`);\n        await page.wait({ selector: '[data-testid=\"primaryColumn\"]' });\n        const deleteResult = unwrapBrowserResult(await page.evaluate(`(async () => {\n            const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));\n            const visible = (el) => !!el && el.offsetParent !== null;\n            const buttonText = (el) => (el.innerText || el.textContent || '').trim();\n            const waitFor = async (fn, { timeoutMs = 10000, intervalMs = 200 } = {}) => {\n                const started = Date.now();\n                while (Date.now() - started < timeoutMs) {\n                    const value = fn();\n                    if (value) return value;\n                    await sleep(intervalMs);\n                }\n                return null;\n            };\n            const findButton = (text) => Array.from(document.querySelectorAll('button, [role=\"button\"]'))","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/twitter/list-delete.js#L92-L128","documentation":"Before deleting, list-delete fetches all of the user's managed lists and looks for one whose id matches listId. If no list matches, it throws CommandExecutionError with a count of how many lists were fetched, so you know the fetch succeeded but the ID is not among your lists. This prevents attempting to delete a list the account does not own.","triggerScenarios":"listsBefore.find((list) => list.id === listId) returns undefined — the ID belongs to another user's list, was already deleted, is a list you follow but don't own, or the ID string mismatches (leading zeros/format).","commonSituations":"Deleting a list that was already removed in another session; typos or stale IDs in scripts; confusing owned lists with subscribed lists; the ListsManagement fetch returning only the first page of lists so a later-page list is missing.","solutions":["Run `twitter list-manage` to list your owned lists and confirm the correct numeric ID","Check whether the list was already deleted; re-run and treat this as a no-op if so","Verify you own the list (you can only delete lists you created, not ones you follow)","If you own many lists, check pagination in getManagedLists to ensure all lists were fetched"],"exampleFix":"// before\nopencli twitter list-delete 999999999999 --confirm true\n// after\nopencli twitter list-manage        # find the real numeric id\nopencli twitter list-delete 123456789 --confirm true","handlingStrategy":"validation","validationCode":"const lists = await getManagedLists(page, headers);\nconst target = lists.find((l) => String(l.id) === String(listId));\nif (!target) throw new Error(`List ${listId} not owned by this account; aborting delete`);","typeGuard":"function findOwnedList(lists, listId) {\n  return (Array.isArray(lists) ? lists : []).find((l) => String(l?.id) === String(listId)) || null;\n}","tryCatchPattern":"try {\n  await runListDelete(page, kwargs);\n} catch (e) {\n  if (/not found among your lists/.test(e.message)) {\n    console.error('Verify the ID via `twitter list-manage` — the list may be deleted or not owned by you.');\n  } else throw e;\n}","preventionTips":["Fetch owned lists and pick IDs from that list rather than hardcoding","Handle already-deleted lists idempotently in scripts","Confirm pagination captures all lists for accounts with many lists"],"tags":["not-found","id-mismatch","twitter"],"backgroundTag":"resource-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}