{"record":{"id":"488c85c110ba3b12","repo":"hcengineering/platform","slug":"billing-url-not-specified","errorCode":null,"errorMessage":"Billing url not specified","messagePattern":"Billing url not specified","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/billing-client/src/client.ts","lineNumber":18,"sourceCode":"import { concatLink, WorkspaceUuid } from '@hcengineering/core'\nimport { BillingError, NetworkError } from './error'\nimport {\n  AiTokensData,\n  AiTranscriptData,\n  BillingStats,\n  DatalakeStats,\n  LiveKitEgressData,\n  LiveKitEgressStats,\n  LiveKitSessionData,\n  LiveKitSessionsStats,\n  LiveKitStats\n} from './types'\n\n/** @public */\nexport function getClient (billingUrl?: string, token?: string): BillingClient {\n  if (billingUrl === undefined || billingUrl == null || billingUrl === '') {\n    throw new Error('Billing url not specified')\n  }\n  if (token === undefined || token == null || token === '') {\n    throw new Error('Token not specified')\n  }\n\n  return new BillingClient(billingUrl, token)\n}\n\nexport class BillingClient {\n  private readonly headers: Record<string, string>\n\n  constructor (\n    private readonly endpoint: string,\n    private readonly token: string\n  ) {\n    this.headers = {\n      Authorization: 'Bearer ' + token,\n      'Content-Type': 'application/json'","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/packages/billing-client/src/client.ts#L1-L36","documentation":"billing-client's getClient factory requires a billing service URL to construct a BillingClient. The URL is validated against undefined, null, and empty string; failing all three means the caller has no endpoint configured, so the client refuses to instantiate. This fails fast instead of producing confusing network errors later.","triggerScenarios":"Calling getClient() with no args, or passing an empty string or null as billingUrl — typically when the URL comes from an unset config variable.","commonSituations":"Missing BILLING_URL env var in deployment config; config loader returning '' as default; forgetting to pass the URL after a refactor of the factory signature.","solutions":["Set the billing service URL (e.g. process.env.BILLING_URL) and pass it as the first argument to getClient.","Validate config at startup so missing URL is reported before the client is needed.","Use a config schema (e.g. zod/env-schema) to require the billing URL."],"exampleFix":"// before\nconst client = getClient(process.env.BILLING_URL, token)\n// after\nif (!process.env.BILLING_URL) throw new Error('BILLING_URL is required')\nconst client = getClient(process.env.BILLING_URL, token)","handlingStrategy":"validation","validationCode":"const billingUrl = process.env.BILLING_URL\nif (!billingUrl) throw new Error('BILLING_URL env var is required')","typeGuard":"function isNonEmptyString(v: unknown): v is string {\n  return typeof v === 'string' && v.trim().length > 0\n}","tryCatchPattern":null,"preventionTips":["Validate billing config (URL and token) at application startup","Use an env schema validator to require BILLING_URL","Never default the billing URL to an empty string"],"tags":["configuration","missing-argument","validation"],"backgroundTag":"missing-env-var","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}