{"record":{"id":"3a046e8557bae9bc","repo":"twentyhq/twenty","slug":"opensidepanelpagefunction-is-not-set","errorCode":null,"errorMessage":"openSidePanelPageFunction is not set","messagePattern":"openSidePanelPageFunction is not set","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/twenty-sdk/src/sdk/front-component/functions/openSidePanelPage.ts","lineNumber":13,"sourceCode":"import { isDefined } from 'twenty-shared/utils';\n\nimport {\n  frontComponentHostCommunicationApi,\n  type OpenSidePanelPageFunction,\n} from '../globals/frontComponentHostCommunicationApi';\n\nexport const openSidePanelPage: OpenSidePanelPageFunction = (params) => {\n  const openSidePanelPageFunction =\n    frontComponentHostCommunicationApi.openSidePanelPage;\n\n  if (!isDefined(openSidePanelPageFunction)) {\n    throw new Error('openSidePanelPageFunction is not set');\n  }\n\n  return openSidePanelPageFunction(params);\n};\n","sourceCodeStart":1,"sourceCodeEnd":18,"githubUrl":"https://github.com/twentyhq/twenty/blob/1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6/packages/twenty-sdk/src/sdk/front-component/functions/openSidePanelPage.ts#L1-L18","documentation":"Thrown by openSidePanelPage when the host application has not registered an openSidePanelPage function on the global frontComponentHostCommunicationApi. This global store is populated by the Twenty host app (the CRM shell) when it mounts a front component. If the SDK function is called outside the host context (e.g. in isolation, in a unit test, or before the host initializes the bridge), the function is undefined.","triggerScenarios":"Calling openSidePanelPage(params) before the host has set frontComponentHostCommunicationApi.openSidePanelPage. This happens when: the front component SDK runs in a non-host environment (standalone, test, SSR), the host bridge initialization failed silently, or the function is called during module evaluation before the host has mounted the component.","commonSituations":"Unit testing a front component that calls openSidePanelPage without mocking the global API. Running the front component in a Storybook or playground without the Twenty host shell. The host app's bridge setup code has a bug or race condition that leaves the function unset. SSR or build-time evaluation that inadvertently executes the function.","solutions":["Ensure openSidePanelPage is only called within a component mounted by the Twenty host shell, not during module load.","In tests, mock the global: (globalThis as any).frontComponentHostCommunicationApi = { openSidePanelPage: jest.fn() }.","Verify the host app correctly populates frontComponentHostCommunicationApi.openSidePanelPage before rendering front components.","Guard the call: check if frontComponentHostCommunicationApi.openSidePanelPage is defined before calling."],"exampleFix":"// before — calling without host context\nimport { openSidePanelPage } from 'twenty-sdk';\nopenSidePanelPage({ page: 'ViewRecord', recordId: '123', objectNameSingular: 'company' });\n\n// after — guard or mock\nconst { frontComponentHostCommunicationApi } = require('twenty-sdk');\nif (!frontComponentHostCommunicationApi.openSidePanelPage) {\n  console.warn('openSidePanelPage not available outside host context');\n  return;\n}\nopenSidePanelPage({ page: 'ViewRecord', recordId: '123', objectNameSingular: 'company' });","handlingStrategy":"type-guard","validationCode":"import { frontComponentHostCommunicationApi } from 'twenty-sdk';\n\nconst canOpenSidePanel = (): boolean => {\n  return frontComponentHostCommunicationApi.openSidePanelPage !== undefined;\n};\n\nif (!canOpenSidePanel()) {\n  console.warn('openSidePanelPage unavailable — not running inside Twenty host.');\n  return;\n}","typeGuard":"import { isDefined } from 'twenty-shared/utils';\nimport { frontComponentHostCommunicationApi } from 'twenty-sdk';\n\nconst isOpenSidePanelAvailable = (): boolean => {\n  return isDefined(frontComponentHostCommunicationApi.openSidePanelPage);\n};","tryCatchPattern":"try {\n  await openSidePanelPage(params);\n} catch (error) {\n  if (error instanceof Error && error.message === 'openSidePanelPageFunction is not set') {\n    console.warn('Side panel navigation not available outside host context.');\n    return;\n  }\n  throw error;\n}","preventionTips":["Only call host-bridge functions from within components mounted by the Twenty host shell.","In tests, always mock frontComponentHostCommunicationApi with the functions you use.","Guard host-bridge calls with isDefined checks for resilient non-host execution."],"tags":["sdk","front-component","host-bridge","global-state"],"backgroundTag":null,"analyzedSha":"1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6","analyzedAt":"2026-08-12T15:37:27.593Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}