jackwener/OpenCLI · error · ArgumentError
Invalid Youdao Note URL
Error message
Invalid Youdao Note URL
What it means
ArgumentError thrown by normalizeShareUrl when the supplied string cannot be parsed by the URL constructor (new URL(value) throws). The library needs an absolute, well-formed URL to hand to page.goto, so malformed input is rejected immediately.
Source
Thrown at clis/youdao/note.js:27
]);
function unwrapEvaluateResult(payload) {
if (payload && !Array.isArray(payload) && typeof payload === 'object' && 'session' in payload && 'data' in payload) {
return payload.data;
}
return payload;
}
function normalizeShareUrl(raw) {
const value = String(raw ?? '').trim();
if (!value) {
throw new ArgumentError('youdao note url cannot be empty', 'Pass a full public share URL from Youdao Notes.');
}
let parsed;
try {
parsed = new URL(value);
} catch {
throw new ArgumentError('Invalid Youdao Note URL', 'Example: https://share.note.youdao.com/ynoteshare/index.html?id=...&type=note');
}
if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') {
throw new ArgumentError('Youdao Note URL must use http or https');
}
if (!ALLOWED_HOSTS.has(parsed.hostname)) {
throw new ArgumentError('Youdao Note URL must be under note.youdao.com or note.youdao.cn');
}
if (!parsed.searchParams.get('id')) {
throw new ArgumentError('Youdao Note URL must include an id query parameter');
}
const type = parsed.searchParams.get('type');
if (type && type !== 'note') {
throw new ArgumentError('youdao note only accepts shared note URLs', 'Shared notebooks are not implemented yet.');
}
return parsed.toString();
}
function formatYoudaoTimestamp(value) {View on GitHub (pinned to 49907e53dc)
Solutions
- Prefix the scheme if missing: prepend 'https://' when the value starts with 'share.note.youdao' or 'note.youdao'
- Trim whitespace and re-copy the full URL from the browser address bar
- URL-encode or strip characters that break URL parsing (spaces, unescaped quotes)
Example fix
// before
const url = 'share.note.youdao.com/ynoteshare/index.html?id=abc';
await youdaoNote(url);
// after
const raw = 'share.note.youdao.com/ynoteshare/index.html?id=abc';
const url = raw.startsWith('http') ? raw : `https://${raw}`;
await youdaoNote(url); Defensive patterns
Strategy: validation
Validate before calling
function isParseableUrl(u) {
try { new URL(u); return true; } catch { return false; }
}
if (!isParseableUrl(inputUrl)) inputUrl = `https://${inputUrl}`; Type guard
function isAbsoluteUrl(v) {
if (typeof v !== 'string') return false;
try { return Boolean(new URL(v)); } catch { return false; }
} Try / catch
try {
await youdaoNote(url);
} catch (e) {
if (String(e.message).includes('Invalid Youdao Note URL')) {
// show the expected format: https://share.note.youdao.com/ynoteshare/index.html?id=...&type=note
} else throw e;
} Prevention
- Pre-parse input with new URL() before calling the command
- Auto-prepend 'https://' for scheme-less hosts
- Trim and re-encode URLs coming from copy/paste or shell arguments
When it happens
Trigger: Passing values like 'share.note.youdao.com/ynoteshare/...' (no scheme), 'not a url', a bare note id, a URL with invalid characters/spaces, or a truncated copy-pasted link to `youdao note <url>`.
Common situations: Users pasting a relative path or just the query string; URLs mangled by shell quoting or markdown trimming; note IDs from email links pasted without the domain; scheme-less URLs from JSON configs.
Related errors
- '${rawInput}' does not look like an autohome series id (a nu
- bilibili follow target must be a valid space.bilibili.com/<u
- chatgpt project commands require a chatgpt.com project id or
- Invalid Chess.com game URL: "${value}" Expected https://www.
- event query parameter must be a numeric event id
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/4aa1a1df391ebc8e.
Report an issue: GitHub.