{"record":{"id":"cf0bbc9d1c9bfb38","repo":"jackwener/OpenCLI","slug":"bilibili-conclusion-api-returned-malformed-part-ou","errorCode":null,"errorMessage":"Bilibili conclusion API returned malformed part outline","messagePattern":"Bilibili conclusion API returned malformed part outline","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/bilibili/summary.js","lineNumber":114,"sourceCode":"        throw new CommandExecutionError('Bilibili conclusion API returned malformed outline');\n    }\n    return { summary, outline };\n}\n\nfunction rowsFromModel(model) {\n    const rows = [{ time: '', content: model.summary }];\n    for (const section of model.outline) {\n        if (!section || typeof section !== 'object' || Array.isArray(section)) {\n            throw new CommandExecutionError('Bilibili conclusion API returned malformed outline section');\n        }\n        const sectionTitle = String(section.title ?? '').trim();\n        const sectionTime = formatTime(section.timestamp);\n        if (sectionTitle) {\n            rows.push({ time: sectionTime, content: `# ${sectionTitle}` });\n        }\n        const points = section.part_outline ?? [];\n        if (!Array.isArray(points)) {\n            throw new CommandExecutionError('Bilibili conclusion API returned malformed part outline');\n        }\n        for (const point of points) {\n            if (!point || typeof point !== 'object' || Array.isArray(point)) {\n                throw new CommandExecutionError('Bilibili conclusion API returned malformed outline point');\n            }\n            const content = String(point.content ?? '').trim();\n            if (content) {\n                rows.push({ time: formatTime(point.timestamp), content });\n            }\n        }\n    }\n    return rows;\n}\n\nvar command = cli({\n    site: 'bilibili',\n    name: 'summary',\n    access: 'read',","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/bilibili/summary.js#L96-L132","documentation":"Each outline section should carry a part_outline array of detail points (defaulting to [] when absent). If part_outline exists but is not an array, rowsFromModel throws this CommandExecutionError because the subsequent for..of iteration over points would fail.","triggerScenarios":"A section object has part_outline set to a non-array (object, string, number) — e.g. a Bilibili schema variant, or sections passed through a transform that collapsed the array.","commonSituations":"API responses where a section has subsection data serialized differently; hand-built model fixtures; caching layers that round-tripped the payload through a format losing array types.","solutions":["Log section.part_outline and its type for the failing section.","Coerce object-shaped part_outline with Object.values() before validation.","Default to [] (skip points) when the shape is unrecognized instead of throwing.","Retry the request — schema anomalies can be per-response.","Compare with a working video's section shape to spot the divergence."],"exampleFix":"// before\nconst points = section.part_outline ?? [];\nif (!Array.isArray(points)) {\n    throw new CommandExecutionError('Bilibili conclusion API returned malformed part outline');\n}\n// after\nlet points = section.part_outline ?? [];\nif (!Array.isArray(points)) {\n    points = points && typeof points === 'object' ? Object.values(points) : [];\n}","handlingStrategy":"validation","validationCode":"for (const s of model?.outline ?? []) {\n  const po = s?.part_outline;\n  if (po != null && !Array.isArray(po)) console.warn('section part_outline is not an array', s?.title);\n}","typeGuard":"function hasValidPartOutline(section) {\n  const po = section?.part_outline;\n  return po === undefined || po === null || (Array.isArray(po) && po.every(p => p && typeof p === 'object'));\n}","tryCatchPattern":"try {\n  const rows = rowsFromModel(model);\n} catch (e) {\n  if (String(e.message).includes('malformed part outline')) {\n    return [{ time: '', content: model.summary }];\n  }\n  throw e;\n}","preventionTips":["Coerce object-shaped part_outline via Object.values()","Default missing part_outline to []","Validate section shape when caching payloads","Compare against a known-good video's response"],"tags":["bilibili","schema-validation","outline","api-response"],"backgroundTag":"schema-validation-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}