{"record":{"id":"b6150ff67043968d","repo":"jackwener/OpenCLI","slug":"bilibili-comments-reply-index-1-was-missing-r","errorCode":null,"errorMessage":"Bilibili comments reply ${index + 1} was missing rpid","messagePattern":"Bilibili comments reply (.+?) was missing rpid","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/bilibili/comments.js","lineNumber":85,"sourceCode":"    if (!data || typeof data !== 'object' || Array.isArray(data)) {\n        throw new CommandExecutionError(`Bilibili ${label} API returned malformed data`);\n    }\n    if (!Object.hasOwn(data, 'top_replies')) {\n        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',","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/bilibili/comments.js#L67-L103","documentation":"Thrown by formatReplyRow when a reply object has no usable rpid (the comment's unique ID): String(reply.rpid ?? '').trim() yields an empty string. The rpid is required output and needed for --parent follow-up queries, so a reply without one cannot be returned.","triggerScenarios":"API returns reply objects lacking the rpid field or with rpid null/empty — e.g. in /x/v2/reply/main or /x/v2/reply/reply responses for comments in an inconsistent state.","commonSituations":"Deleted or shadow-removed comments still present in the list; older API payloads where the id field is named differently; scraping layers that strip numeric fields.","solutions":["Retry the command; the affected comment may reappear with a valid rpid","Fetch fewer comments (--limit) or skip the offending page","Check whether the library version expects rpid while the API now returns rpid_str or another field, and update","Report the specific video/rpid upstream if reproducible"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const replyMissingRpid = replies.find((r) => !String(r?.rpid ?? '').trim());\nif (replyMissingRpid) console.warn('a reply is missing rpid');","typeGuard":"function hasRpid(reply) {\n    return !!reply && typeof reply === 'object' && String(reply.rpid ?? '').trim().length > 0;\n}","tryCatchPattern":"try {\n    const rows = await bilibiliComments(bvid);\n} catch (err) {\n    if (/missing rpid/.test(err.message)) {\n        // retry or skip the offending comment\n    } else throw err;\n}","preventionTips":["Check the replies column before using an rpid with --parent","Update the library if the API renamed the id field","Retry — deleted comments may vanish from the list","Sanitize inputs so only known-good rpids are chained"],"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"}