{"record":{"id":"b7e7fbe2cf07185b","repo":"jackwener/OpenCLI","slug":"label-string-payload-error-b7e7fb","errorCode":null,"errorMessage":"${label}: ${String(payload.error)}","messagePattern":"\\$\\{label\\}: \\$\\{String\\(payload\\.error\\)\\}","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/weibo/utils.js","lineNumber":22,"sourceCode":"import { AuthRequiredError, CommandExecutionError } from '@jackwener/opencli/errors';\n/**\n * `page.evaluate` may return either the raw IIFE value or a\n * `{ session, data }` envelope depending on the browser-bridge version.\n * Adapter code that inspected the payload directly (e.g. `Array.isArray`,\n * truthiness checks on uid strings) silently received the envelope wrapper\n * instead of the inner value. This helper normalizes both shapes so callers\n * can keep their existing checks unchanged.\n */\nexport function unwrapEvaluateResult(payload) {\n    if (payload && !Array.isArray(payload) && typeof payload === 'object' && 'session' in payload && 'data' in payload) {\n        return payload.data;\n    }\n    return payload;\n}\nexport function requireArrayEvaluateResult(payload, label) {\n    if (!Array.isArray(payload)) {\n        if (payload && typeof payload === 'object' && 'error' in payload) {\n            throw new CommandExecutionError(`${label}: ${String(payload.error)}`);\n        }\n        throw new CommandExecutionError(`${label} returned malformed extraction payload`);\n    }\n    return payload;\n}\nexport function requireObjectEvaluateResult(payload, label) {\n    if (!payload || Array.isArray(payload) || typeof payload !== 'object') {\n        throw new CommandExecutionError(`${label} returned malformed extraction payload`);\n    }\n    return payload;\n}\n/** Get the currently logged-in user's uid from Vue store or config API. */\nexport async function getSelfUid(page) {\n    const uid = unwrapEvaluateResult(await page.evaluate(`\n    (() => {\n      const app = document.querySelector('#app')?.__vue_app__;\n      const store = app?.config?.globalProperties?.$store;\n      const uid = store?.state?.config?.config?.uid;","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/weibo/utils.js#L4-L40","documentation":"requireArrayEvaluateResult validates that an evaluate payload is an array. If instead it is an object with an `error` key, the library throws a CommandExecutionError prefixed with the extraction label and the raw error text. This surfaces in-page failures from shared weibo extraction helpers (called by data/rawData wrappers).","triggerScenarios":"Calling a weibo data/rawData command whose injected script returned {error: '...'} instead of an array; the label in the message identifies which extractor failed.","commonSituations":"Weibo rate-limiting or anti-bot interstitials cause the in-page script to report an error; login expired; the extractor's target element is missing after a Weibo UI update.","solutions":["Read the `${label}: ...` prefix to identify which extractor failed and what the in-page error said.","Re-authenticate the weibo.com session and retry.","Retry after a delay if the error indicates rate limiting/anti-bot blocking.","Update the CLI if Weibo changed its page structure."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"const payload = unwrapEvaluateResult(raw);\nif (!Array.isArray(payload)) {\n  throw new Error(payload?.error ? `weibo: ${payload.error}` : 'weibo: non-array payload');\n}","typeGuard":"function isArrayPayload(p) {\n  return Array.isArray(p);\n}\nfunction payloadError(p) {\n  return p && typeof p === 'object' && !Array.isArray(p) && 'error' in p ? p.error : null;\n}","tryCatchPattern":"try {\n  const list = requireArrayEvaluateResult(raw, 'weibo search');\n} catch (err) {\n  if (String(err.message).includes('malformed')) {\n    console.error('Extractor returned bad shape; check login/DOM');\n  } else throw err;\n}","preventionTips":["Check the label prefix to identify the failing extractor","Validate login state before running extraction","Retry with backoff on suspected rate limiting","Pin CLI versions and test after Weibo UI changes"],"tags":["weibo","validation","payload-shape","command-execution"],"backgroundTag":"malformed-extraction-payload","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}