{"record":{"id":"e0277ac8c1409fec","repo":"Hmbown/CodeWhale","slug":"invalid-base-url-args-baseurl","errorCode":null,"errorMessage":"invalid --base-url: ${args.baseUrl}","messagePattern":"invalid --base-url: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"web/scripts/compare-deployed-facts.mjs","lineNumber":105,"sourceCode":"      expected.latestPublishedRelease?.tag ?? null,\n      receipt.latestPublishedRelease?.tag ?? null,\n    ],\n  ];\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 = {","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/web/scripts/compare-deployed-facts.mjs#L87-L123","documentation":"main() validates the --base-url value by constructing a URL object; if parsing fails it throws with the offending value. This guard runs before any network request so a malformed or missing URL fails immediately with a clear message.","triggerScenarios":"Running the script without --base-url (undefined), or with a value that is not an absolute URL — e.g. `localhost:8080` without scheme, `deploy.example.com`, or a value containing unescaped spaces.","commonSituations":"Forgetting the https:// scheme; passing a relative path; shell mangling `&` or spaces in the URL; copying a URL with trailing punctuation.","solutions":["Pass a full absolute URL including scheme: --base-url https://deploy.example.com","Quote the URL in the shell so special characters survive: --base-url \"https://example.com/path\".","Verify the flag is actually set (a missing flag yields `invalid --base-url: undefined`).","Note: the URL must parse AND use http/https — a valid but non-http(s) URL fails the next check."],"exampleFix":"// before\nnode compare-deployed-facts.mjs --base-url localhost:8080\n// after\nnode compare-deployed-facts.mjs --base-url http://localhost:8080","handlingStrategy":"validation","validationCode":"let u; try { u = new URL(args.baseUrl); } catch { throw new Error(\"--base-url must be an absolute http(s) URL\"); } if (!/^https?:$/.test(u.protocol)) throw new Error(\"--base-url must use http or https\");","typeGuard":"const isHttpUrl = (s) => { try { return /^https?:$/.test(new URL(s).protocol); } catch { return false; } };","tryCatchPattern":"try { main(); } catch (e) { if (e.message.startsWith(\"invalid --base-url\")) console.error(\"Pass an absolute URL, e.g. --base-url https://deploy.example.com\"); }","preventionTips":["Always include the scheme (http:// or https://).","Quote URLs in the shell.","Default the base URL in a wrapper script for your environment.","Validate with `new URL()` in any calling automation first."],"tags":["cli","url","validation"],"backgroundTag":"invalid-url-format","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}