Hmbown/CodeWhale · error · Error
--base-url must use http or https
Error message
--base-url must use http or https
What it means
After URL() parses successfully, the script requires the protocol to be exactly http: or https: via /^https?:$/. Any other valid URL — ftp:, file:, ws: — triggers `--base-url must use http or https` because the script will immediately build `new URL('/api/facts', baseUrl)` and fetch it over HTTP(S).
Source
Thrown at web/scripts/compare-deployed-facts.mjs:108
];
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 = {
sourceRevision: expectedRevision,
version: facts.version,
providerCount: facts.providers.length,View on GitHub (pinned to 8880682c63)
Solutions
- Serve the facts over HTTP(S) and point --base-url at that
- For local checks, use http://127.0.0.1:<port>
- Fix scheme typos (httpss:// → https://)
Example fix
# before --base-url ftp://mirror.internal # after --base-url http://mirror.internal
Defensive patterns
Strategy: type-guard
Validate before calling
const candidate = new URL(String(raw).trim());
if (!/^https?:$/.test(candidate.protocol)) {
console.error('--base-url must use http or https');
process.exit(2);
} Type guard
function isHttpBaseUrl(url) {
return url instanceof URL && /^https?:$/.test(url.protocol);
} Prevention
- Serve facts endpoints over HTTP(S); other schemes are never valid inputs to this checker
- Add a URL lint step for deployment URLs used in CI verification scripts
When it happens
Trigger: --base-url ftp://host, file:///path, or ws://host; scheme typos such as httpss:// that still parse as a URL with a weird scheme.
Common situations: Internal tooling URLs with custom schemes pasted as the deployment base; local file paths; typos in the scheme.
Related errors
- invalid --base-url: ${args.baseUrl}
- 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/e150d504d34daff9.
Report an issue: GitHub.