jackwener/OpenCLI · error · ArgumentError
youdao note url cannot be empty
Error message
youdao note url cannot be empty
What it means
ArgumentError thrown by normalizeShareUrl when the positional `url` argument is empty, null, undefined, or whitespace-only. The library requires a full Youdao share URL to load in a headless browser; without it there is nothing to fetch. This is an upfront input validation so the failure happens before any browser work.
Source
Thrown at clis/youdao/note.js:21
const ALLOWED_HOSTS = new Set([
'share.note.youdao.com',
'note.youdao.com',
'share.note.youdao.cn',
'note.youdao.cn',
]);
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') {View on GitHub (pinned to 49907e53dc)
Solutions
- Pass the complete public share URL, e.g. https://share.note.youdao.com/ynoteshare/index.html?id=<id>&type=note
- Check the shell variable/config key holding the URL actually has a non-empty value before invoking
- If you only have the note ID, build the URL: `https://share.note.youdao.com/ynoteshare/index.html?id=${id}&type=note`
Example fix
// before
await run(['youdao', 'note', urlFromConfig]);
// after
if (!urlFromConfig || !urlFromConfig.trim()) {
throw new Error('config missing youdao share url');
}
await run(['youdao', 'note', urlFromConfig.trim()]); Defensive patterns
Strategy: validation
Validate before calling
function hasShareUrl(u) {
return typeof u === 'string' && u.trim().length > 0;
}
if (!hasShareUrl(inputUrl)) throw new Error('provide a youdao share url first'); Type guard
function isNonEmptyString(v) {
return typeof v === 'string' && v.trim().length > 0;
} Try / catch
try {
await youdaoNote(url);
} catch (e) {
if (String(e.message).includes('url cannot be empty')) {
// prompt user / fix config for the url input
} else throw e;
} Prevention
- Validate CLI inputs for non-empty trimmed values before invoking
- Fail fast in scripts when a config/env variable holding the URL is empty
- Build the full URL from a note id with a helper rather than passing raw ids
When it happens
Trigger: Calling `youdao note` (or command.func) with an empty/missing positional url argument, e.g. `youdao note ''`, `youdao note ' '`, or a kwargs object where kwargs.url is undefined or null.
Common situations: CLI invocations where the URL was stored in a shell variable that expanded to empty; scripts piping config values that are missing; automation passing undefined because a prior parsing step failed; users pasting only a note ID instead of the full share URL.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- series_id must be a non-empty value
- Invalid Chess.com username "${value}" Usernames are 3-25 cha
- coingecko derivatives limit must be a positive integer
- limit must be a positive integer
- Search keyword cannot be empty
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/74c06eec3ed7a587.
Report an issue: GitHub.