From 0881e35d649f8a5df245168225e2f8035c30de3f Mon Sep 17 00:00:00 2001 From: Marie <51697796+ijreilly@users.noreply.github.com> Date: Mon, 28 Apr 2025 15:36:19 +0200 Subject: [PATCH] Throw error if attempting to open RecordPage without recordId (#11768) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes https://github.com/twentyhq/core-team-issues/issues/857 The issue was caused by the fact that the preview chip was accidentally made clickable while not linked to any record id: Capture d’écran 2025-04-28 à 15 17 32 this was fixed by [this PR](https://github.com/twentyhq/twenty/pull/11745) (@etiennejouan) It was causing the side panel to open while the record id was empty, while this recordId is used in query filters (as it should be to fetch record data), leading the queries to fail. Let's early return with an error instead as it does not make sense to open the record page with an empty recordId. --------- Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --- .../record-page/components/CommandMenuRecordPage.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/twenty-front/src/modules/command-menu/pages/record-page/components/CommandMenuRecordPage.tsx b/packages/twenty-front/src/modules/command-menu/pages/record-page/components/CommandMenuRecordPage.tsx index 659c37d90..e1f8c6262 100644 --- a/packages/twenty-front/src/modules/command-menu/pages/record-page/components/CommandMenuRecordPage.tsx +++ b/packages/twenty-front/src/modules/command-menu/pages/record-page/components/CommandMenuRecordPage.tsx @@ -37,9 +37,13 @@ export const CommandMenuRecordPage = () => { throw new Error(`Object name is not defined`); } + if (!viewableRecordId) { + throw new Error(`Record id is not defined`); + } + const { objectNameSingular, objectRecordId } = useRecordShowPage( - viewableRecordNameSingular ?? '', - viewableRecordId ?? '', + viewableRecordNameSingular, + viewableRecordId, ); const commandMenuPageInstanceId = useComponentInstanceStateContext(