{"record":{"id":"aff3d7d4f8c19a77","repo":"jackwener/OpenCLI","slug":"huodongxing-eventtype-must-be-1-offline-or-2-on","errorCode":null,"errorMessage":"huodongxing eventType must be 1 (offline) or 2 (online)","messagePattern":"huodongxing eventType must be 1 \\(offline\\) or 2 \\(online\\)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/huodongxing/events.js","lineNumber":163,"sourceCode":"    if (!range) return true;\n    return range.start <= end && range.end >= start;\n  });\n  return filtered.map((row, index) => ({ ...row, rank: index + 1 }));\n}\n\nexport function buildEventsUrl(args = {}) {\n  const dateRange = requireDateRangeArgs(args);\n  const params = new URLSearchParams();\n  params.set('orderby', 'o');\n  params.set('d', 'ts');\n  appendIfPresent(params, 'date', dateRange.date);\n  appendIfPresent(params, 'dateTo', dateRange.dateTo);\n  appendIfPresent(params, 'tag', args.tag);\n  appendIfPresent(params, 'city', args.city);\n  const eventType = cleanText(args.eventType);\n  if (eventType) {\n    if (eventType !== '1' && eventType !== '2') {\n      throw new ArgumentError('huodongxing eventType must be 1 (offline) or 2 (online)');\n    }\n    params.set('eventType', eventType);\n  }\n  appendIfPresent(params, 'qs', args.qs);\n  return `${BASE_URL}?${params.toString()}`;\n}\n\nexport function extractEventRowsPayload(limit = 20) {\n  const maxLimit = 50;\n  const rawLimit = limit ?? 20;\n  const count = typeof rawLimit === 'number' ? rawLimit : Number(String(rawLimit).trim());\n  if (!Number.isInteger(count) || count <= 0 || count > maxLimit) {\n    return {\n      ok: false,\n      code: 'INVALID_LIMIT',\n      message: `huodongxing limit must be a positive integer <= ${maxLimit}`,\n    };\n  }","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/huodongxing/events.js#L145-L181","documentation":"buildEventsUrl restricts the optional eventType query parameter to '1' (offline events) or '2' (online events), matching the site's API. Any other cleaned string throws this ArgumentError before the request is built.","triggerScenarios":"Passing args.eventType with any value other than the strings '1' or '2' to the events URL builder, e.g. 'online', '3', or ' true'.","commonSituations":"Using human-readable event type names instead of the site's numeric codes; passing a number instead of a string; guessing an enum value not documented by huodongxing.","solutions":["Use exactly the string '1' for offline or '2' for online events","Omit eventType entirely to query both kinds","Convert a boolean/enum in your tool layer to '1'/'2' before calling"],"exampleFix":"// before\nbuildEventsUrl({ eventType: 'online' });\n// after\nbuildEventsUrl({ eventType: '2' }); // or '1' for offline","handlingStrategy":"validation","validationCode":"const EVENT_TYPES = new Set(['1','2']);\nif (args.eventType != null && !EVENT_TYPES.has(String(args.eventType))) {\n  throw new Error('eventType must be \"1\" (offline) or \"2\" (online)');\n}","typeGuard":"const isValidEventType = v => v == null || (typeof v === 'string' && ['1','2'].includes(v));","tryCatchPattern":"try { buildEventsUrl(args); } catch (e) { if (e instanceof ArgumentError && /eventType/.test(e.message)) { /* map 'online'->'2', 'offline'->'1' and retry */ } else throw e; }","preventionTips":["Treat eventType as the site's numeric enum, not free text","Validate in your tool schema with enum: ['1','2']","Omit the field instead of passing null/empty variants you invent"],"tags":["argument-validation","enum","cli"],"backgroundTag":"invalid-enum-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}