{"record":{"id":"b77ec4e8fe82771f","repo":"hcengineering/platform","slug":"accounts-url-or-token-is-not-defined-b77ec4","errorCode":null,"errorMessage":"Accounts URL or token is not defined","messagePattern":"Accounts URL or token is not defined","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/calendar-resources/src/api.ts","lineNumber":65,"sourceCode":"export async function disconnect (integration: Integration): Promise<void> {\n  const integrationClient = await getIntegrationClient()\n  const result = await integrationClient.removeIntegration(integration.socialId, integration.workspaceUuid)\n  if (result !== undefined && result.connectionRemoved) {\n    await signout(integration, integrationClient)\n  }\n}\n\nexport async function disconnectAll (integration: Integration): Promise<void> {\n  const integrationClient = await getIntegrationClient()\n  await integrationClient.removeConnection(integration)\n  await signout(integration, integrationClient)\n}\n\nexport async function getIntegrationClient (): Promise<IntegrationClient> {\n  const accountsUrl = getMetadata(login.metadata.AccountsUrl)\n  const token = getMetadata(presentation.metadata.Token)\n  if (accountsUrl === undefined || token === undefined) {\n    throw new Error('Accounts URL or token is not defined')\n  }\n  return getIntegrationClientRaw(accountsUrl, token, calendarIntegrationKind, 'calendar')\n}\n","sourceCodeStart":47,"sourceCodeEnd":69,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/plugins/calendar-resources/src/api.ts#L47-L69","documentation":"getIntegrationClient builds an IntegrationClient for the calendar by reading the Accounts service URL and auth token from metadata. If either is undefined it cannot talk to the accounts service and throws before creating the client.","triggerScenarios":"Calling getIntegrationClient (via integrationClient factory) when login.metadata.AccountsUrl or presentation.metadata.Token is unset — typically a misconfigured frontend or headless context without login metadata.","commonSituations":"Self-hosted deployments without AccountsUrl metadata configured; code running outside a logged-in presentation context; environment where accounts service URL changed and metadata not updated; unit tests invoking integration code without metadata bootstrap.","solutions":["Configure login.metadata.AccountsUrl in deployment metadata","Ensure presentation.metadata.Token is available (authenticated context)","In tests/headless code, set the required metadata via setMetadata before calling"],"exampleFix":"// before: metadata missing, throws\nawait getIntegrationClient()\n// after: seed metadata first\nsetMetadata(login.metadata.AccountsUrl, 'https://accounts.example.com')\nsetMetadata(presentation.metadata.Token, token)\nawait getIntegrationClient()","handlingStrategy":"validation","validationCode":"const accountsUrl = getMetadata(login.metadata.AccountsUrl)\nconst token = getMetadata(presentation.metadata.Token)\nif (accountsUrl === undefined || token === undefined) throw new Error('Calendar integration requires AccountsUrl and token metadata')","typeGuard":"const canBuildIntegrationClient = (): boolean =>\n  getMetadata(login.metadata.AccountsUrl) !== undefined &&\n  getMetadata(presentation.metadata.Token) !== undefined","tryCatchPattern":"try {\n  const client = await getIntegrationClient()\n} catch (err) {\n  if ((err as Error).message.includes('Accounts URL or token is not defined')) {\n    logger.error('Metadata bootstrap incomplete for calendar integration')\n  } else throw err\n}","preventionTips":["Configure login.metadata.AccountsUrl at application bootstrap","In headless/test code, call setMetadata for AccountsUrl and Token before integration calls","Centralize metadata requirements in a startup validation routine"],"tags":["configuration","metadata","accounts"],"backgroundTag":"missing-env-var","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}