{"record":{"id":"5bceb721af2e7338","repo":"jackwener/OpenCLI","slug":"manus-label-returned-a-malformed-api-payload","errorCode":null,"errorMessage":"Manus ${label} returned a malformed API payload","messagePattern":"Manus (.+?) returned a malformed API payload","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/manus/_utils.js","lineNumber":74,"sourceCode":"        payload.details,\n    ];\n    return candidates.find((value) => typeof value === 'string' && value.trim())?.trim() || '';\n}\n\nexport function requireObject(payload, label) {\n    const value = unwrapEvaluateResult(payload);\n    if (value?.__authRequired) {\n        throw new AuthRequiredError(MANUS_DOMAIN, value.message || 'Authentication required — please sign in to Manus in the browser');\n    }\n    if (value?.__httpError) {\n        const message = extractErrorMessage(value);\n        throw new CommandExecutionError(message ? `Manus ${label} failed (HTTP ${value.__httpError}): ${message}` : `Manus ${label} failed (HTTP ${value.__httpError})`);\n    }\n    if (value?.__error) {\n        throw new CommandExecutionError(`Manus ${label} failed: ${value.message || value.__error}`);\n    }\n    if (!value || typeof value !== 'object' || Array.isArray(value)) {\n        throw new CommandExecutionError(`Manus ${label} returned a malformed API payload`);\n    }\n    return value;\n}\n\nexport function requireArray(value, label) {\n    if (!Array.isArray(value)) {\n        throw new CommandExecutionError(`Manus ${label} returned a malformed API payload`);\n    }\n    return value;\n}\n\nexport function requireString(value, label) {\n    const text = String(value ?? '').trim();\n    if (!text) {\n        throw new CommandExecutionError(`Manus ${label} returned a malformed API payload`);\n    }\n    return text;\n}","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/manus/_utils.js#L56-L92","documentation":"CommandExecutionError thrown by requireObject() when, after all known error markers are ruled out, the unwrapped value is still not a plain object. It indicates the Manus endpoint returned something the CLI's contract does not recognize.","triggerScenarios":"unwrapEvaluateResult yields null/undefined/array/primitive — e.g. the evaluate returned undefined, a serialized HTML page, or the endpoint's top-level response changed from object to array/string.","commonSituations":"Manus API response shape change after an update, evaluate result lost due to page navigation, proxy/CDN returning HTML challenge pages (bot protection).","solutions":["Log the raw payload before requireObject to see the actual value.","Check for bot-protection/CDN interstitials by opening Manus in the browser.","Update the CLI to match the new response schema.","Retry if the page navigated mid-evaluate (transient)."],"exampleFix":"// before\nconst data = await requireObject(payload, 'sessions');\n// after\nif (payload == null) console.error('raw evaluate result:', payload);\nconst data = await requireObject(payload, 'sessions');","handlingStrategy":"type-guard","validationCode":"if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {\n  console.error('unexpected Manus payload:', typeof raw, String(raw).slice(0, 200));\n}","typeGuard":"function isPlainObject(v) { return v !== null && typeof v === 'object' && !Array.isArray(v); }","tryCatchPattern":"try {\n  const data = await manusData();\n} catch (e) {\n  if (/malformed API payload/.test(e.message)) {\n    console.error('Unrecognized Manus response — check for bot-protection pages or API changes');\n  } else throw e;\n}","preventionTips":["Confirm no CDN/bot-protection interstitial when opening manus.com.","Log raw evaluate results in development before shipping scripts.","Update the CLI after Manus API releases."],"tags":["payload","schema-drift","api"],"backgroundTag":"malformed-api-response","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}