{"record":{"id":"a8b755de12293db7","repo":"jackwener/OpenCLI","slug":"youdao-note-extractor-returned-a-malformed-payload","errorCode":null,"errorMessage":"Youdao note extractor returned a malformed payload","messagePattern":"Youdao note extractor returned a malformed payload","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/youdao/note.js","lineNumber":175,"sourceCode":"          var aiPayload = JSON.parse(ai.aiSummary);\n          summary = cleanText(aiPayload.description || '');\n          if (Array.isArray(aiPayload.keywords)) {\n            for (var i = 0; i < aiPayload.keywords.length; i += 1) {\n              var keyword = aiPayload.keywords[i];\n              if (keyword && keyword.title) keywords.push(cleanText(((keyword.emoji || '') + ' ' + keyword.title).trim()));\n            }\n          }\n        } catch {}\n      }\n      return [true, title, content, summary, keywords.join(' | '), contentData.ct || null, contentData.sz || null, hasContentField, rawContent.length, window.location.href];\n    })()\n  `;\n}\n\nfunction normalizeExtractionResult(payload, sourceUrl) {\n  const data = unwrapEvaluateResult(payload);\n  if (!Array.isArray(data)) {\n    throw new CommandExecutionError('Youdao note extractor returned a malformed payload');\n  }\n  const ok = data[0] === true;\n  if (!ok) {\n    const reason = typeof data[1] === 'string' && data[1].trim() ? data[1].trim() : 'unknown_parser_failure';\n    if (reason === 'auth') {\n      throw new AuthRequiredError('note.youdao.com', 'Youdao shared note requires login or additional permission');\n    }\n    if (reason === 'not_found') {\n      throw new EmptyResultError('youdao note', 'The shared note is missing, expired, cancelled, or inaccessible.');\n    }\n    throw new CommandExecutionError(`Youdao note parser failed: ${reason}`);\n  }\n  const title = String(data[1] ?? '');\n  const content = String(data[2] ?? '');\n  const summary = String(data[3] ?? '');\n  const keywords = String(data[4] ?? '');\n  const createTime = data[5];\n  const fileSize = data[6];","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/youdao/note.js#L157-L193","documentation":"CommandExecutionError thrown by normalizeExtractionResult when the payload returned by the in-page extractor is not an array (even after unwrapEvaluateResult unwraps {session,data} envelopes). The extractor contract requires [ok, ...fields]; anything else means the page runtime changed or evaluate returned something unexpected, so the library cannot interpret the result.","triggerScenarios":"page.evaluate returning an object/string instead of the IIFE's array (browser extension interference, a page navigation replacing the document mid-evaluate, a wrapper runner returning its own envelope with an unexpected shape, or evaluate serializing a promise/error object).","commonSituations":"Youdao shipping a new page framework that breaks the injected script; headless browser plugins injecting scripts that alter evaluate return values; SPA re-render/navigation between goto and evaluate; automation runners that wrap evaluate results in custom envelopes unwrapEvaluateResult doesn't recognize.","solutions":["Retry the command; transient SPA navigation or hydration timing can corrupt the evaluate result","Update the CLI/library to the latest version in case the extractor was patched for Youdao page changes","Increase post-load wait before evaluate (the command already waits ~2s) or reduce extension interference by running with a clean browser profile","Inspect the raw payload (log it) to see what shape evaluate actually returned and report it upstream"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isExtractorPayload(p) {\n  const data = p && !Array.isArray(p) && typeof p === 'object' && 'data' in p ? p.data : p;\n  return Array.isArray(data);\n}","tryCatchPattern":"try {\n  await youdaoNote(url);\n} catch (e) {\n  if (String(e.message).includes('malformed payload')) {\n    // retry once, then surface 'youdao page structure changed' to the operator\n  } else throw e;\n}","preventionTips":["Retry transiently before treating it as a hard failure","Run with a clean browser profile (no script-injecting extensions)","Keep the CLI updated for Youdao page changes","Log the raw evaluate payload for diagnosis"],"tags":["command-execution-error","malformed-payload","browser-extraction","page-structure-change"],"backgroundTag":"extractor-malformed-payload","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}