{"record":{"id":"197e35e64ee34b7e","repo":"jackwener/OpenCLI","slug":"failed-to-open-youdao-note-url-error-instanceof","errorCode":null,"errorMessage":"Failed to open Youdao Note URL: ${error instanceof Error ? error.message : String(error)}","messagePattern":"Failed to open Youdao Note URL: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/youdao/note.js","lineNumber":234,"sourceCode":"\nvar command = cli({\n  site: 'youdao',\n  name: 'note',\n  access: 'read',\n  description: 'Read a public shared Youdao Note',\n  domain: 'share.note.youdao.com',\n  strategy: Strategy.PUBLIC,\n  browser: true,\n  args: [\n    { name: 'url', positional: true, required: true, help: 'Full share URL of the Youdao Note' },\n  ],\n  columns: ['title', 'content', 'summary', 'keywords', 'created_at', 'file_size', 'url'],\n  func: async function(page, kwargs) {\n    const url = normalizeShareUrl(kwargs.url);\n    try {\n      await page.goto(url);\n    } catch (error) {\n      throw new CommandExecutionError(`Failed to open Youdao Note URL: ${error instanceof Error ? error.message : String(error)}`);\n    }\n    try {\n      await page.wait({ selector: '#root, .file-name, body', timeout: 10 });\n    } catch {\n      await page.wait(3).catch(function() {});\n    }\n    await page.wait(2).catch(function() {});\n    let payload;\n    try {\n      payload = await page.evaluate(buildExtractorJs());\n    } catch (error) {\n      throw new CommandExecutionError(`Youdao note extractor failed: ${error instanceof Error ? error.message : String(error)}`);\n    }\n    return [normalizeExtractionResult(payload, url)];\n  },\n});\n\nexport var __test__ = {","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/youdao/note.js#L216-L252","documentation":"The command wraps page.goto(url) in try/catch and converts any navigation failure (network error, DNS failure, timeout, invalid URL) into a CommandExecutionError with the underlying message. It means the browser automation could not open the normalized Youdao share URL at all.","triggerScenarios":"page.goto throws: DNS resolution failure, TLS error, connection refused/timeout, offline environment, proxy blocking youdao.com, or an invalid URL passed via kwargs.url.","commonSituations":"Corporate proxy/firewall blocking the domain; no internet access in CI; mistyped share link; Youdao endpoint outage or regional block.","solutions":["Check network connectivity and that the URL opens in a normal browser","Fix/normalize the share URL passed with --url","Configure proxy settings (HTTP_PROXY/HTTPS_PROXY) if behind a firewall","Retry — transient timeouts often resolve; add retry/backoff around the command"],"exampleFix":"// before\nawait cli youdao note --url 'youdao.com/invalid'\n// after\nawait cli youdao note --url 'https://note.youdao.com/ynoteshare/index.html?id=valid-id'","handlingStrategy":"try-catch","validationCode":"const u = new URL(rawUrl);\nif (!/youdao\\.com$/.test(u.hostname)) throw new Error(`Not a Youdao URL: ${u.href}`);\nif (!(await fetch(u.href, { method: 'HEAD' })).ok) throw new Error('Share URL unreachable');","typeGuard":null,"tryCatchPattern":"try {\n  await cli.youdao.note({ url });\n} catch (e) {\n  if (/Failed to open Youdao Note URL/.test(e.message)) {\n    console.error('Navigation failed:', e.message);\n    // check proxy/offline, then retry with backoff\n  } else throw e;\n}","preventionTips":["Verify the share URL in a normal browser before automation","Check DNS/proxy/firewall access to youdao.com from the host","Add retry with exponential backoff for transient navigation timeouts","Validate URL format before invoking"],"tags":["network","browser-automation","navigation"],"backgroundTag":"page-navigation-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}