jackwener/OpenCLI · error · ArgumentError
Youdao Note URL must include an id query parameter
Error message
Youdao Note URL must include an id query parameter
What it means
ArgumentError thrown by normalizeShareUrl when the URL, though on an allowed host, has no 'id' query parameter (or it is empty). The id uniquely identifies the shared note on Youdao's side; without it the page cannot resolve a note and the extractor would return nothing useful.
Source
Thrown at clis/youdao/note.js:36
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) {
if (value == null || value === '') return '';
const numeric = Number(value);
if (!Number.isFinite(numeric) || numeric <= 0) return String(value);
const millis = numeric < 10_000_000_000 ? numeric * 1000 : numeric;
const date = new Date(millis);
if (Number.isNaN(date.getTime())) return String(value);
return date.toISOString();
}
View on GitHub (pinned to 49907e53dc)
Solutions
- Include the id parameter: https://share.note.youdao.com/ynoteshare/index.html?id=<your-note-id>&type=note
- Re-generate the share link in Youdao Notes and copy the complete URL including query string
- Check your code isn't stripping search params (e.g. new URL(u).origin + pathname loses the id)
Example fix
// before const url = new URL(shareLink).origin + new URL(shareLink).pathname; await youdaoNote(url); // id dropped // after await youdaoNote(shareLink); // keep full URL with ?id=...&type=note
Defensive patterns
Strategy: validation
Validate before calling
function hasNoteId(u) {
try { return Boolean(new URL(u).searchParams.get('id')); } catch { return false; }
}
if (!hasNoteId(inputUrl)) throw new Error('share URL missing ?id= parameter'); Type guard
function urlHasIdParam(v) {
try { return new URL(v).searchParams.get('id') !== null; } catch { return false; }
} Try / catch
try {
await youdaoNote(url);
} catch (e) {
if (String(e.message).includes('id query parameter')) {
// regenerate the share link; don't strip the query string
} else throw e;
} Prevention
- Never rebuild a URL as origin+pathname; keep the full search string
- Avoid URL shorteners/param strippers on share links
- Copy links only after the share dialog finalizes
When it happens
Trigger: Passing 'https://share.note.youdao.com/ynoteshare/index.html?type=note' (no id), '...index.html?id=' (empty id), or a base URL where the id was lost by aggressive URL stripping/shortening or a redirect that dropped the query string.
Common situations: URL shorteners or analytics libs stripping query params; manually constructed URLs missing the id; saving only the path portion of the share link; copying the link before the share dialog finished generating the id.
Related errors
- ${label} must be a valid hltv.org URL
- ${label} must be an hltv.org URL
- URL must be on reuters.com, got ${url}
- youdao note url cannot be empty
- archive search sort must be one of ${SORT_OPTIONS.join(', ')
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/847158da613bacc7.
Report an issue: GitHub.