{"record":{"id":"e150d504d34daff9","repo":"Hmbown/CodeWhale","slug":"base-url-must-use-http-or-https","errorCode":null,"errorMessage":"--base-url must use http or https","messagePattern":"--base-url must use http or https","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"web/scripts/compare-deployed-facts.mjs","lineNumber":108,"sourceCode":"  ];\n  for (const [field, expectedValue, deployedValue] of checks) {\n    if (expectedValue !== deployedValue) {\n      differences.push({ field, expected: expectedValue, deployed: deployedValue });\n    }\n  }\n  return differences;\n}\n\nasync function main() {\n  const args = parseArgs(process.argv.slice(2));\n  let baseUrl;\n  try {\n    baseUrl = new URL(args.baseUrl);\n  } catch {\n    throw new Error(`invalid --base-url: ${args.baseUrl}`);\n  }\n  if (!/^https?:$/.test(baseUrl.protocol)) {\n    throw new Error(\"--base-url must use http or https\");\n  }\n\n  const expectedRevision = args.expectedRevision || localRevision();\n  if (!expectedRevision || !/^[0-9a-f]{40}$/i.test(expectedRevision)) {\n    throw new Error(\"expected revision must be an exact 40-character Git SHA\");\n  }\n  if (!Number.isInteger(args.attempts) || args.attempts < 1 || args.attempts > 20) {\n    throw new Error(\"--attempts must be an integer from 1 to 20\");\n  }\n  if (!Number.isFinite(args.retryDelayMs) || args.retryDelayMs < 0 || args.retryDelayMs > 30_000) {\n    throw new Error(\"--retry-delay-ms must be between 0 and 30000\");\n  }\n\n  const facts = buildFacts();\n  const expected = {\n    sourceRevision: expectedRevision,\n    version: facts.version,\n    providerCount: facts.providers.length,","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/web/scripts/compare-deployed-facts.mjs#L90-L126","documentation":"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).","triggerScenarios":"--base-url ftp://host, file:///path, or ws://host; scheme typos such as httpss:// that still parse as a URL with a weird scheme.","commonSituations":"Internal tooling URLs with custom schemes pasted as the deployment base; local file paths; typos in the scheme.","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://)"],"exampleFix":"# before\n--base-url ftp://mirror.internal\n# after\n--base-url http://mirror.internal","handlingStrategy":"type-guard","validationCode":"const candidate = new URL(String(raw).trim());\nif (!/^https?:$/.test(candidate.protocol)) {\n  console.error('--base-url must use http or https');\n  process.exit(2);\n}","typeGuard":"function isHttpBaseUrl(url) {\n  return url instanceof URL && /^https?:$/.test(url.protocol);\n}","tryCatchPattern":null,"preventionTips":["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"],"tags":["cli","validation","url","web"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}