{"record":{"id":"9f7a6a885d479c0a","repo":"jackwener/OpenCLI","slug":"label-returned-an-unexpected-payload-shape-exp-9f7a6a","errorCode":null,"errorMessage":"${label} returned an unexpected payload shape; expected an object.","messagePattern":"(.+?) returned an unexpected payload shape; expected an object\\.","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/dongchedi/utils.js","lineNumber":110,"sourceCode":"    const pp = extractPageProps(html);\n    if (!pp) {\n        throw new CommandExecutionError(\n            `dongchedi ${contextHint} returned no __NEXT_DATA__`,\n            'Dongchedi likely changed its page structure, or the request hit an anti-bot page.',\n        );\n    }\n    if (isFallbackShell(pp)) {\n        throw new CommandExecutionError(\n            `dongchedi ${contextHint}`,\n            'Dongchedi served its empty fallback shell — the id may not exist or the URL form changed.',\n        );\n    }\n    return pp;\n}\n\nexport function assertPlainObject(value, label) {\n    if (!value || typeof value !== 'object' || Array.isArray(value)) {\n        throw new CommandExecutionError(`${label} returned an unexpected payload shape; expected an object.`);\n    }\n    return value;\n}\n\nexport function requireArray(value, label) {\n    if (!Array.isArray(value)) {\n        throw new CommandExecutionError(`${label} returned an unexpected payload shape; expected an array.`);\n    }\n    return value;\n}\n\nexport function requireStableId(value, label) {\n    const id = String(value ?? '').trim();\n    if (!/^\\d+$/.test(id) || id === '0') {\n        throw new CommandExecutionError(`${label} did not include a stable numeric id.`);\n    }\n    return id;\n}","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/dongchedi/utils.js#L92-L128","documentation":"A CommandExecutionError thrown by assertPlainObject (clis/dongchedi/utils.js:110), a schema guard used by the head/ov parsers. It fires when a pageProps field that the parser expects to be a plain JSON object is instead null, an array, a string, or another non-object type. It protects downstream property accesses from crashing on unexpected payload shapes after upstream layout changes.","triggerScenarios":"Calling a dongchedi command whose parser invokes assertPlainObject (e.g. head/ov data blocks) when the site returns null for that block (missing data, soft-deleted content), wraps it in an array, or changed its type in a layout update.","commonSituations":"Scraping series or reviews whose overview block is absent; Dongchedi shipping a schema change (object → array) in a redeploy; fixtures/tests feeding hand-built payloads of the wrong shape.","solutions":["Inspect the live pageProps to see the actual type of the labeled field and update the parser to match.","If the data legitimately doesn't exist for this item, treat it as empty output rather than forcing the parse.","Catch CommandExecutionError in the command wrapper and report which labeled block was malformed.","When building test fixtures, ensure the mocked field matches the real SSR shape (a plain object)."],"exampleFix":"// before\nconst head = assertPlainObject(pp.someBlock, 'head'); // throws if null\n// after\nconst head = pp.someBlock && !Array.isArray(pp.someBlock)\n  ? assertPlainObject(pp.someBlock, 'head')\n  : defaultEmptyHead;","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"function isPlainObject(v) {\n  return v !== null && typeof v === 'object' && !Array.isArray(v);\n}","tryCatchPattern":"if (!isPlainObject(pp.expectedBlock)) {\n  return emptyResult('expected block missing'); // pre-validate before the parser throws\n}\nconst head = assertPlainObject(pp.expectedBlock, 'head');","preventionTips":["Type-check pageProps blocks before passing them to parsers.","Keep fixtures mirroring the real SSR shapes (plain objects).","Treat null blocks as 'data absent', not 'wrong shape', where appropriate.","Re-verify payload shapes after any known Dongchedi deploy."],"tags":["schema-validation","parsing","dongchedi","type-mismatch"],"backgroundTag":"schema-validation-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}