{"record":{"id":"36de9f477c774642","repo":"jackwener/OpenCLI","slug":"top-by-engagement-cannot-be-combined-with-outp","errorCode":null,"errorMessage":"--top-by-engagement cannot be combined with --output-file","messagePattern":"--top-by-engagement cannot be combined with --output-file","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/twitter/bookmarks.js","lineNumber":193,"sourceCode":"    args: [\n        { name: 'limit', type: 'int', default: 20, help: 'Maximum number of bookmarks to return (default 20). Ignored when --all is set.' },\n        { name: 'all', type: 'bool', default: false, help: 'Fetch all bookmark pages until exhausted. Prefer --output-file for large archives.' },\n        { name: 'resume-file', type: 'string', help: 'Resume file for long-running all-pages bookmark syncs.' },\n        { name: 'output-file', type: 'string', help: 'Write all-page results to JSONL. Requires --all and --resume-file.' },\n        { name: 'max-pages', type: 'int', help: `Optional pagination safety cap (default ${DEFAULT_MAX_PAGINATION_PAGES}; raised automatically with --all).` },\n        { name: 'top-by-engagement', type: 'int', default: 0, help: 'When set to N>0, re-rank the bookmarks by weighted engagement (likes×1 + retweets×3 + replies×2 + bookmarks×5 + log10(views+1)×0.5) and return the top N. Default 0 keeps the API\\'s native (saved-time) ordering. Incompatible with --output-file.' },\n    ],\n    columns: ['id', 'author', 'text', 'likes', 'retweets', 'bookmarks', 'created_at', 'url', 'has_media', 'media_urls', 'media_posters'],\n    func: async (page, kwargs) => {\n        const fetchAll = Boolean(kwargs.all);\n        const limit = fetchAll ? Number.POSITIVE_INFINITY : (kwargs.limit || 20);\n        const resumeFile = resolveOptionalFilePath(kwargs['resume-file'], '--resume-file');\n        const outputFile = resolveOptionalFilePath(kwargs['output-file'], '--output-file');\n        const useOutputFile = Boolean(fetchAll && outputFile);\n        const maxPages = resolveMaxPages(kwargs, fetchAll);\n        const topByEngagement = Number(kwargs['top-by-engagement'] || 0);\n        if (useOutputFile && topByEngagement > 0) {\n            throw new ArgumentError('--top-by-engagement cannot be combined with --output-file');\n        }\n        if (outputFile && !fetchAll) {\n            throw new ArgumentError('--output-file requires --all');\n        }\n        if (resumeFile && !fetchAll) {\n            throw new ArgumentError('--resume-file requires --all');\n        }\n        if (outputFile && !resumeFile) {\n            throw new ArgumentError('--output-file requires --resume-file so partial archives remain resumable');\n        }\n        const cookies = await page.getCookies({ url: 'https://x.com' });\n        const ct0 = cookies.find((c) => c.name === 'ct0')?.value || null;\n        if (!ct0)\n            throw new AuthRequiredError('x.com', 'Not logged into x.com (no ct0 cookie)');\n        const queryId = await resolveTwitterQueryId(page, 'Bookmarks', BOOKMARKS_QUERY_ID);\n        const headers = JSON.stringify({\n            'Authorization': `Bearer ${decodeURIComponent(TWITTER_BEARER_TOKEN)}`,\n            'X-Csrf-Token': ct0,","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/twitter/bookmarks.js#L175-L211","documentation":"The bookmarks CLI validates flag combinations before doing any work. --top-by-engagement re-ranks in-memory results and returns top N, while --output-file streams pages to JSONL; combining them is unsupported, so the command throws this ArgumentError immediately.","triggerScenarios":"Invoking `twitter bookmarks --all --output-file archive.jsonl --resume-file r.json --top-by-engagement 10`.","commonSituations":"Assuming ranking works with JSONL archiving; copying flags from two different example commands into one invocation.","solutions":["Remove --top-by-engagement when archiving with --output-file.","Or drop --output-file/--resume-file and run in-memory with --top-by-engagement N (optionally with --all).","Do the ranking yourself afterwards on the JSONL archive (likes×1 + retweets×3 + replies×2 + bookmarks×5 + log10(views+1)×0.5)."],"exampleFix":"// before\ncli twitter bookmarks --all --output-file a.jsonl --resume-file r.json --top-by-engagement 10\n// after (choose one mode)\ncli twitter bookmarks --all --output-file a.jsonl --resume-file r.json\n# or\ncli twitter bookmarks --all --top-by-engagement 10","handlingStrategy":"validation","validationCode":"const flags = ['--all', '--output-file', a, '--resume-file', r, '--top-by-engagement', '10'];\nif (flags.includes('--output-file') && Number(kwargs['top-by-engagement'] || 0) > 0) {\n  throw new Error('drop --top-by-engagement when archiving with --output-file');\n}","typeGuard":"null","tryCatchPattern":"try {\n  await run(args);\n} catch (e) {\n  if (String(e.message).includes('--top-by-engagement cannot be combined with --output-file')) {\n    const cleaned = args.filter((f, i) => f !== '--top-by-engagement' && args[i - 1] !== '--top-by-engagement');\n    await run(cleaned);\n  } else throw e;\n}","preventionTips":["Treat --top-by-engagement and --output-file as mutually exclusive modes.","Validate flag combinations in wrapper scripts before invoking the CLI.","Read flag help text: the help for --top-by-engagement states the incompatibility.","Do ranking as a post-processing step on the JSONL archive."],"tags":["argument-error","cli","incompatible-flags"],"backgroundTag":"incompatible-cli-flags","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}