Hmbown/CodeWhale · error · Error
invalid --base-url: ${args.baseUrl}
Error message
invalid --base-url: ${args.baseUrl} What it means
main() runs `new URL(args.baseUrl)` (default 'https://codewhale.net') and converts a parse failure into `invalid --base-url: ${args.baseUrl}`. URL() rejects strings without a valid scheme — 'example.com', values with stray spaces or control characters, or an empty string.
Source
Thrown at web/scripts/compare-deployed-facts.mjs:105
expected.latestPublishedRelease?.tag ?? null,
receipt.latestPublishedRelease?.tag ?? null,
],
];
for (const [field, expectedValue, deployedValue] of checks) {
if (expectedValue !== deployedValue) {
differences.push({ field, expected: expectedValue, deployed: deployedValue });
}
}
return differences;
}
async function main() {
const args = parseArgs(process.argv.slice(2));
let baseUrl;
try {
baseUrl = new URL(args.baseUrl);
} catch {
throw new Error(`invalid --base-url: ${args.baseUrl}`);
}
if (!/^https?:$/.test(baseUrl.protocol)) {
throw new Error("--base-url must use http or https");
}
const expectedRevision = args.expectedRevision || localRevision();
if (!expectedRevision || !/^[0-9a-f]{40}$/i.test(expectedRevision)) {
throw new Error("expected revision must be an exact 40-character Git SHA");
}
if (!Number.isInteger(args.attempts) || args.attempts < 1 || args.attempts > 20) {
throw new Error("--attempts must be an integer from 1 to 20");
}
if (!Number.isFinite(args.retryDelayMs) || args.retryDelayMs < 0 || args.retryDelayMs > 30_000) {
throw new Error("--retry-delay-ms must be between 0 and 30000");
}
const facts = buildFacts();
const expected = {View on GitHub (pinned to 8880682c63)
Solutions
- Include the scheme: `--base-url https://codewhale.net`
- Trim whitespace from env-provided URLs before passing them
- If the value looks correct, print it with delimiters — invisible characters fail URL() too
Example fix
# before --base-url example.com # after --base-url https://example.com
Defensive patterns
Strategy: validation
Validate before calling
const raw = String(args.baseUrl ?? 'https://codewhale.net').trim();
let candidate;
try {
candidate = new URL(raw);
} catch {
console.error(`invalid --base-url: ${raw} (include the scheme, e.g. https://host)`);
process.exit(2);
} Try / catch
try {
baseUrl = new URL(args.baseUrl);
} catch (error) {
if (error instanceof TypeError) { console.error(`invalid --base-url: ${args.baseUrl}`); process.exit(2); }
throw error;
} Prevention
- Normalize env-provided URLs with trim() before parsing
- Always paste URLs with an explicit scheme
When it happens
Trigger: Passing a bare host without a scheme (--base-url example.com), a value with leading/trailing whitespace or invisible characters, or an empty --base-url.
Common situations: Copy-pasting a domain from a browser address bar without https://; env-injected URLs carrying whitespace; a default overridden with a malformed value in CI.
Related errors
- --base-url must use http or https
- unknown argument: ${arg}
- expected revision must be an exact 40-character Git SHA
- Invalid GitHub repository: ${repo}
- Invalid release tag: ${tag}
AI-assisted analysis of Hmbown/CodeWhale@8880682c63 (2026-08-16).
Data as JSON: /api/errors/e0277ac8c1409fec.
Report an issue: GitHub.