{"record":{"id":"e9909fc7cb48810c","repo":"jackwener/OpenCLI","slug":"weibo-favorites-name-must-be-max-limit","errorCode":null,"errorMessage":"weibo favorites ${name} must be <= ${MAX_LIMIT}","messagePattern":"weibo favorites (.+?) must be <= (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"warning","filePath":"clis/weibo/favorites.js","lineNumber":15,"sourceCode":"import { cli, Strategy } from '@jackwener/opencli/registry';\nimport { ArgumentError, CommandExecutionError, EmptyResultError } from '@jackwener/opencli/errors';\nimport { getSelfUid, requireArrayEvaluateResult, unwrapEvaluateResult } from './utils.js';\n\nconst DEFAULT_LIMIT = 20;\nconst MAX_LIMIT = 50;\n\nfunction parsePositiveInt(value, name, defaultValue) {\n  const raw = value ?? defaultValue;\n  const number = Number(raw);\n  if (!Number.isInteger(number) || number <= 0) {\n    throw new ArgumentError(`weibo favorites ${name} must be a positive integer`);\n  }\n  if (number > MAX_LIMIT) {\n    throw new ArgumentError(`weibo favorites ${name} must be <= ${MAX_LIMIT}`);\n  }\n  return number;\n}\n\nfunction parseFavoriteCard(card, favUrl) {\n  const raw = String(card?.text ?? '');\n  const lines = raw.split('\\n');\n\n  let author = '';\n  let time = '';\n  let source = '';\n  let content = '';\n  let likes = '0';\n  let comments = '0';\n  let reposts = '0';\n\n  for (const line of lines) {\n    const t = line.trim();","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/weibo/favorites.js#L1-L33","documentation":"clis/weibo/favorites.js:15 — parsePositiveInt throws ArgumentError(`weibo favorites ${name} must be <= ${MAX_LIMIT}`) when a valid positive integer option exceeds MAX_LIMIT (50). The cap exists because the scraper reads the visible favorites page; requesting more than 50 cannot be satisfied reliably.","triggerScenarios":"Calling `weibo favorites` with limit=100, 500, or any integer > 50; scripts passing a page-size constant that exceeds the CLI's cap.","commonSituations":"Users assuming the API paginates arbitrarily like official Weibo APIs; reusing a limit from another tool with a higher cap; batch export scripts requesting 'all' favorites via a huge number.","solutions":["Cap the request at 50: use limit: 50 and paginate/aggregate multiple calls if you need more","Clamp in your own code before calling: Math.min(desiredLimit, 50)","For bulk exports, loop with limit=50 and deduplicate results between pages","Do not set limit to an enormous number hoping the CLI clamps — it throws instead"],"exampleFix":"// before\nawait cli.run('weibo favorites', { limit: 200 }); // ArgumentError\n// after\nconst limit = Math.min(Math.max(1, Number(cfg.limit) || 20), 50);\nawait cli.run('weibo favorites', { limit });","handlingStrategy":"validation","validationCode":"const MAX_LIMIT = 50;\nfunction clampLimit(v, fallback = 20) {\n  const n = v == null || v === '' ? fallback : Number(v);\n  if (!Number.isInteger(n) || n <= 0) return fallback;\n  return Math.min(n, MAX_LIMIT);\n}","typeGuard":"function isWithinLimit(v, max = 50) { return typeof v === 'number' && Number.isInteger(v) && v > 0 && v <= max; }","tryCatchPattern":"try {\n  await cli.run('weibo favorites', { limit });\n} catch (e) {\n  if (e instanceof Error && /must be <= 50/.test(e.message)) {\n    console.error('Cap favorites limit at 50; paginate for more.');\n  }\n  throw e;\n}","preventionTips":["Clamp with Math.min(desired, 50) before every call","Paginate with repeated limit=50 calls for bulk retrieval","Document the 50 cap in any wrapper you build around the CLI","Never pass 'all'-style sentinel values like 9999"],"tags":["validation","limit","weibo","parameters"],"backgroundTag":"parameter-out-of-range","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}