{"record":{"id":"85b3e871d91785bc","repo":"hcengineering/platform","slug":"accounts-url-not-specified","errorCode":null,"errorMessage":"Accounts url not specified","messagePattern":"Accounts url not specified","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"foundations/core/packages/account-client/src/client.ts","lineNumber":280,"sourceCode":"  getWorkspaceUsersWithPermission: (params: { permission: string }) => Promise<AccountUuid[]>\n\n  verify2fa: (code: string) => Promise<LoginInfo>\n  createApiToken: (name: string, workspaceUuid: WorkspaceUuid, expiryDays: number) => Promise<ApiTokenResult>\n  listApiTokens: () => Promise<ApiTokenInfo[]>\n  revokeApiToken: (tokenId: string) => Promise<void>\n\n  setCookie: () => Promise<void>\n  deleteCookie: () => Promise<void>\n\n  generate2faSecret: () => Promise<{ secret: string, url: string }>\n  enable2fa: (secret: string, code: string) => Promise<void>\n  disable2fa: (code: string) => Promise<void>\n}\n\n/** @public */\nexport function getClient (accountsUrl?: string, token?: string, retryTimeoutMs?: number): AccountClient {\n  if (accountsUrl === undefined) {\n    throw new Error('Accounts url not specified')\n  }\n\n  return new AccountClientImpl(accountsUrl, token, retryTimeoutMs)\n}\n\ninterface Request {\n  method: string\n  params: Record<string, any>\n}\n\nclass AccountClientImpl implements AccountClient {\n  private readonly request: RequestInit\n  private readonly rpc: typeof this._rpc\n\n  constructor (\n    private readonly url: string,\n    private readonly token?: string,\n    retryTimeoutMs?: number","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/foundations/core/packages/account-client/src/client.ts#L262-L298","documentation":"getClient is the factory for AccountClient; it validates that an accountsUrl argument was provided before constructing the client. If accountsUrl is undefined it throws 'Accounts url not specified'. The library throws this because the client cannot build any API request URLs without a base accounts service URL.","triggerScenarios":"Calling getClient() with no arguments, or explicitly passing undefined for the first parameter — typically when a config value (e.g. process.env.ACCOUNTS_URL) was never set and undefined flows through.","commonSituations":"Missing environment variable / config entry for the accounts service URL in a new environment (local dev, CI, staging); config loader returning undefined defaults; forgetting to pass the URL after refactoring the call site.","solutions":["Pass the accounts URL explicitly: getClient('https://accounts.example.com', token).","Fix the config/env lookup that yields undefined (set the environment variable or config key).","Add a startup-time config validation that fails fast with a clear message before calling getClient.","Use a default/fallback URL for non-production environments if appropriate."],"exampleFix":"// before\nconst client = getClient(process.env.ACCOUNTS_URL, token); // undefined\n// after\nconst url = process.env.ACCOUNTS_URL;\nif (!url) throw new Error('ACCOUNTS_URL env var must be set');\nconst client = getClient(url, token);","handlingStrategy":"validation","validationCode":"// Before calling getClient:\nfunction requireAccountsUrl(source) {\n  const url = source?.accountsUrl;\n  if (typeof url !== 'string' || url.length === 0) {\n    throw new Error('accountsUrl must be a non-empty string before calling getClient');\n  }\n  return url;\n}\nconst client = getClient(requireAccountsUrl(config), token);","typeGuard":"function isAccountsUrl(v) {\n  return typeof v === 'string' && v.length > 0;\n}","tryCatchPattern":"try {\n  const client = getClient(config.accountsUrl, token);\n} catch (e) {\n  if (e.message === 'Accounts url not specified') {\n    console.error('ACCOUNTS_URL is not configured; set the env var or config entry.');\n  }\n  throw e;\n}","preventionTips":["Validate required config (accountsUrl) at application startup, fail fast","Never pass possibly-undefined env vars straight into getClient","Use non-empty defaults per environment (dev/staging/prod)","Centralize config loading so URL presence is checked once"],"tags":["configuration","validation","account-client","missing-argument"],"backgroundTag":"missing-required-config","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}