{"record":{"id":"6adda2800b5582f7","repo":"jackwener/OpenCLI","slug":"bilibili-comments-reply-index-1-was-missing-c","errorCode":null,"errorMessage":"Bilibili comments reply ${index + 1} was missing ctime","messagePattern":"Bilibili comments reply (.+?) was missing ctime","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/bilibili/comments.js","lineNumber":89,"sourceCode":"        throw new CommandExecutionError(`Bilibili ${label} API did not return top_replies`);\n    }\n    if (!Array.isArray(data.top_replies)) {\n        throw new CommandExecutionError(`Bilibili ${label} API returned malformed top_replies`);\n    }\n    return data.top_replies;\n}\n\nfunction formatReplyRow(reply, index) {\n    if (!reply || typeof reply !== 'object' || Array.isArray(reply)) {\n        throw new CommandExecutionError(`Bilibili comments reply ${index + 1} was malformed`);\n    }\n    const rpid = String(reply.rpid ?? '').trim();\n    if (!rpid) {\n        throw new CommandExecutionError(`Bilibili comments reply ${index + 1} was missing rpid`);\n    }\n    const ctime = Number(reply.ctime);\n    if (!Number.isFinite(ctime)) {\n        throw new CommandExecutionError(`Bilibili comments reply ${index + 1} was missing ctime`);\n    }\n    return {\n        rank: index + 1,\n        rpid,\n        author: String(reply.member?.uname ?? ''),\n        text: String(reply.content?.message ?? '').replace(/\\n/g, ' ').trim(),\n        likes: reply.like ?? 0,\n        replies: reply.rcount ?? 0,\n        time: new Date(ctime * 1000).toISOString().slice(0, 16).replace('T', ' '),\n    };\n}\n\ncli({\n    site: 'bilibili',\n    name: 'comments',\n    access: 'read',\n    description: '获取 B站视频评论（官方 API；用 --parent <rpid> 读取某条评论下的「楼中楼」回复；用 --top 只看置顶评论）',\n    domain: 'www.bilibili.com',","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/bilibili/comments.js#L71-L107","documentation":"Thrown by formatReplyRow when reply.ctime cannot be converted to a finite number (Number(reply.ctime) is NaN/Infinity). ctime (creation unix timestamp) is required to render the time column, so replies without it are rejected.","triggerScenarios":"A reply object in the API response has ctime missing, null, or a non-numeric value (e.g. a string like '' or an ISO date that Number() rejects as NaN).","commonSituations":"Pinned or specially injected comment entries lacking timestamps; API schema changes (ctime moved/renamed); proxies that alter numeric fields.","solutions":["Retry — often a transient anomaly for one entry","Update the CLI to a version matching the current Bilibili reply schema","Pre-sanitize or default ctime if you control the fetching layer","Verify with raw API output whether the field is now named differently"],"exampleFix":"// before\nconst ctime = Number(reply.ctime);\nif (!Number.isFinite(ctime)) {\n    throw new CommandExecutionError(`Bilibili comments reply ${index + 1} was missing ctime`);\n}\n// after\nconst ctime = Number(reply.ctime ?? 0);\nif (!Number.isFinite(ctime)) {\n    throw new CommandExecutionError(`Bilibili comments reply ${index + 1} was missing ctime`);\n} // or default to 0 and render empty time","handlingStrategy":"validation","validationCode":"const badCtime = replies.find((r) => !Number.isFinite(Number(r?.ctime)));\nif (badCtime) console.warn('a reply lacks a numeric ctime');","typeGuard":"function hasCtime(reply) {\n    return !!reply && typeof reply === 'object' && Number.isFinite(Number(reply.ctime));\n}","tryCatchPattern":"try {\n    const rows = await bilibiliComments(bvid);\n} catch (err) {\n    if (/missing ctime/.test(err.message)) {\n        // retry or accept rows without a usable timestamp\n    } else throw err;\n}","preventionTips":["Keep the CLI current with Bilibili's reply schema","Default or skip entries lacking ctime when processing raw data","Retry once on transient single-entry anomalies","Inspect raw API JSON when the error reproduces for one video"],"tags":["bilibili","missing-field","validation"],"backgroundTag":"missing-required-field","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}