{"record":{"id":"248606b5e2a41aea","repo":"hcengineering/platform","slug":"token-not-specified","errorCode":null,"errorMessage":"Token not specified","messagePattern":"Token not specified","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/billing-client/src/client.ts","lineNumber":21,"sourceCode":"import {\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'\n    }\n  }\n","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/packages/billing-client/src/client.ts#L3-L39","documentation":"getClient in billing-client requires an auth token alongside the billing URL. If token is undefined, null, or empty, it throws because BillingClient cannot authenticate any request without it. Like the URL check, this fails fast at construction time.","triggerScenarios":"Calling getClient(billingUrl) without the second argument, or passing an empty/unset token variable (e.g. process.env.BILLING_TOKEN not set).","commonSituations":"Token env var missing in the deployment; token rotated/removed from secret store; calling code written for an older getClient signature that took only a URL.","solutions":["Provide a valid billing token as the second argument to getClient.","Check that the token env var/secret is present in the environment before creating the client.","Load the token from your secret manager and fail fast at startup if absent."],"exampleFix":"// before\nconst client = getClient(url) // token missing\n// after\nconst token = process.env.BILLING_TOKEN\nif (!token) throw new Error('BILLING_TOKEN is required')\nconst client = getClient(url, token)","handlingStrategy":"validation","validationCode":"const token = process.env.BILLING_TOKEN\nif (!token) throw new Error('BILLING_TOKEN 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":["Load the billing token from a secret manager before creating the client","Validate token presence at startup alongside the URL","Rotate and test tokens in staging before production"],"tags":["configuration","authentication","missing-argument"],"backgroundTag":"missing-api-token","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}