hcengineering/platform · error · Error
Accounts url not specified
Error message
Accounts url not specified
What it means
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.
Source
Thrown at foundations/core/packages/account-client/src/client.ts:280
getWorkspaceUsersWithPermission: (params: { permission: string }) => Promise<AccountUuid[]>
verify2fa: (code: string) => Promise<LoginInfo>
createApiToken: (name: string, workspaceUuid: WorkspaceUuid, expiryDays: number) => Promise<ApiTokenResult>
listApiTokens: () => Promise<ApiTokenInfo[]>
revokeApiToken: (tokenId: string) => Promise<void>
setCookie: () => Promise<void>
deleteCookie: () => Promise<void>
generate2faSecret: () => Promise<{ secret: string, url: string }>
enable2fa: (secret: string, code: string) => Promise<void>
disable2fa: (code: string) => Promise<void>
}
/** @public */
export function getClient (accountsUrl?: string, token?: string, retryTimeoutMs?: number): AccountClient {
if (accountsUrl === undefined) {
throw new Error('Accounts url not specified')
}
return new AccountClientImpl(accountsUrl, token, retryTimeoutMs)
}
interface Request {
method: string
params: Record<string, any>
}
class AccountClientImpl implements AccountClient {
private readonly request: RequestInit
private readonly rpc: typeof this._rpc
constructor (
private readonly url: string,
private readonly token?: string,
retryTimeoutMs?: numberView on GitHub (pinned to 63e28dc964)
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.
Example fix
// before
const client = getClient(process.env.ACCOUNTS_URL, token); // undefined
// after
const url = process.env.ACCOUNTS_URL;
if (!url) throw new Error('ACCOUNTS_URL env var must be set');
const client = getClient(url, token); Defensive patterns
Strategy: validation
Validate before calling
// Before calling getClient:
function requireAccountsUrl(source) {
const url = source?.accountsUrl;
if (typeof url !== 'string' || url.length === 0) {
throw new Error('accountsUrl must be a non-empty string before calling getClient');
}
return url;
}
const client = getClient(requireAccountsUrl(config), token); Type guard
function isAccountsUrl(v) {
return typeof v === 'string' && v.length > 0;
} Try / catch
try {
const client = getClient(config.accountsUrl, token);
} catch (e) {
if (e.message === 'Accounts url not specified') {
console.error('ACCOUNTS_URL is not configured; set the env var or config entry.');
}
throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.
Related errors
- Billing url not specified
- No screen access granted
- Notification id is required
- Ticks per second has an invalid value: must be >= 1 && <= 10
- Interval must be a finite number >= 1 (seconds)
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/85b3e871d91785bc.
Report an issue: GitHub.