jackwener/OpenCLI · error · ArgumentError
Invalid source URL: "${url}"
Error message
Invalid source URL: "${url}" What it means
parseSourceUrl throws this ArgumentError when the --url value cannot be parsed by the WHATWG URL constructor (new URL throws), e.g. a missing scheme, spaces, or malformed host. The second detail argument tells the user the URL must be a valid http:// or https:// URL. It is the first of two URL validations before the value is accepted as a NotebookLM source URL.
Source
Thrown at clis/notebooklm/add-source.js:73
}
export function buildRegisterFileSourceArgs(projectId, filename) {
return [
[[filename]],
projectId,
[2],
[1, null, null, null, null, null, null, null, null, null, [1]],
];
}
export function parseSourceUrl(value) {
const url = String(value ?? '').trim();
if (!url) return '';
let parsed;
try {
parsed = new URL(url);
} catch {
throw new ArgumentError(`Invalid source URL: "${url}"`, 'URL must be a valid http:// or https:// URL.');
}
if ((parsed.protocol !== 'http:' && parsed.protocol !== 'https:') || !parsed.hostname) {
throw new ArgumentError(`Invalid source URL: "${url}"`, 'URL must start with http:// or https://.');
}
return parsed.toString();
}
export function parseSourceText(value) {
if (value === undefined || value === null) return null;
const text = String(value);
if (!text.trim()) throw new ArgumentError('--content must not be empty');
if (text.length > MAX_TEXT_SOURCE_BYTES) {
throw new ArgumentError(`--content exceeds ${MAX_TEXT_SOURCE_BYTES} bytes; split into smaller sources or upload as a file.`);
}
return text;
}
export function parseSourceTitle(value, fallback) {View on GitHub (pinned to 49907e53dc)
Solutions
- Add the scheme: prefix the value with https:// if it was omitted.
- Fix typos in the scheme/host and remove stray whitespace or smart quotes.
- Quote the URL in your shell so &, ?, and spaces survive intact.
- Test with `new URL(value)` in Node to confirm it parses before running the command.
Example fix
// before
addSource({ url: 'example.com/article' });
// after
addSource({ url: 'https://example.com/article' }); Defensive patterns
Strategy: validation
Validate before calling
function isParseableUrl(v) {
try { new URL(String(v ?? '').trim()); return true; } catch { return false; }
} Type guard
function isValidHttpUrl(v) {
try { const u = new URL(String(v ?? '').trim()); return (u.protocol === 'http:' || u.protocol === 'https:') && !!u.hostname; } catch { return false; }
} Try / catch
try {
await addSource({ url });
} catch (e) {
if (e instanceof ArgumentError && e.message.startsWith('Invalid source URL')) {
console.error(`Add https:// and re-check the URL: "${url}"`);
} else throw e;
} Prevention
- Always include the https:// scheme in stored URLs.
- Trim and validate URLs with new URL() before passing them.
- Quote URLs in shells so & and ? aren't interpreted.
- Strip smart quotes/whitespace when copying URLs from docs or chat.
When it happens
Trigger: Passing --url 'example.com/page' (no scheme), '--url htp://...' (typo'd scheme), a URL with unencoded spaces, or an empty-but-truthy string that fails URL parsing.
Common situations: Copy-pasting a URL that lost its https:// prefix; smart-quote characters from docs breaking the parse; shell stripping the scheme; forgetting to quote URLs containing & or ? in some shells.
Related errors
- Cannot resolve Bilibili BV ID from input: ${String(kwargs.bv
- --${name} must be a positive integer, got ${JSON.stringify(r
- Discord channel navigation requires both guild_id and channe
- Invalid Jira --fields selection
- Invalid Jira field id in --fields
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/b68a3f33b200c384.
Report an issue: GitHub.