hcengineering/platform · error
Email is not defined in integration
Error message
Email is not defined in integration
What it means
After validating service URL/token, signout determines the account email from integration.data?.email or the stored connection's email. If neither is present the service cannot be told which account to sign out, so this error is thrown.
Source
Thrown at plugins/calendar-resources/src/api.ts:37
import { type Integration } from '@hcengineering/account-client'
import {
type IntegrationClient,
getIntegrationClient as getIntegrationClientRaw,
request
} from '@hcengineering/integration-client'
import calendar from './plugin'
import { calendarIntegrationKind } from '@hcengineering/calendar'
export async function signout (integration: Integration, client: IntegrationClient): Promise<void> {
const url = getMetadata(calendar.metadata.CalendarServiceURL)
const token = getMetadata(presentation.metadata.Token)
if (url === undefined || token === undefined) {
throw new Error('Calendar service URL or token is not defined')
}
const connection = await client.getConnection(integration)
const email = integration.data?.email ?? connection?.data?.email
if (email === undefined) {
throw new Error('Email is not defined in integration')
}
await request({
baseUrl: url,
path: `/signout?value=${email}`,
method: 'GET',
token
})
}
export async function disconnect (integration: Integration): Promise<void> {
const integrationClient = await getIntegrationClient()
const result = await integrationClient.removeIntegration(integration.socialId, integration.workspaceUuid)
if (result !== undefined && result.connectionRemoved) {
await signout(integration, integrationClient)
}
}
export async function disconnectAll (integration: Integration): Promise<void> {View on GitHub (pinned to 63e28dc964)
Solutions
- Set the email on the integration data (re-run the connect/OAuth flow) before disconnecting
- Check the connection record and add the missing email
- Delete the broken integration record and reconnect the calendar account
Example fix
// before
await signout(integration, client) // throws: no email
// after
const email = integration.data?.email ?? (await client.getConnection(integration))?.data?.email
if (email !== undefined) {
await signout(integration, client)
} Defensive patterns
Strategy: type-guard
Validate before calling
const conn = await client.getConnection(integration)
const email = integration.data?.email ?? conn?.data?.email
if (email === undefined) { /* repair integration or skip signout */ } Type guard
const hasEmail = (i: Integration, c?: IntegrationConnection): i is Integration & { data: { email: string } } =>
typeof (i.data?.email ?? c?.data?.email) === 'string' Try / catch
try {
await signout(integration, client)
} catch (err) {
if ((err as Error).message === 'Email is not defined in integration') {
await repairOrRecreateIntegration(integration) // reconnect flow to capture email
} else throw err
} Prevention
- Always capture and store the account email during the connect/OAuth flow
- Validate integration records include email before allowing them to be persisted
- During disconnectAll, tolerate integrations missing email instead of failing the whole batch
When it happens
Trigger: Calling signout for an Integration whose data.email is undefined and whose stored IntegrationConnection has no email — e.g. a partially created or corrupted calendar integration record.
Common situations: Integration created through a broken OAuth flow that never stored the email; manually seeded integration records without email; older integration records created before email was captured, hit during disconnectAll.
Related errors
- Parent not found: ${issue.clickupParentId} (for task: ${clic
- Project not found: ${issue.clickupProjectName} (for task: ${
- Task cannot be imported: ${clickupId} (No parent)
- Integration not found: ${JSON.stringify(integrationKey)}
- Calendar service URL or token is not defined
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/dbcd668b8147a130.
Report an issue: GitHub.