Skip to content

Commit 6e2748d

Browse files
committed
chore(OUT-2157): do not report sentry error for malformed tokens
1 parent 887d306 commit 6e2748d

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

src/app/client-preview/page.tsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,18 @@ export default async function ClientPreviewPage({
6060
const token = tokenParsed.data
6161
const copilotClient = new CopilotAPI(token)
6262
const tokenPayload = await copilotClient.getTokenPayload()
63-
if (!tokenPayload) {
64-
console.info('Failing token payload', tokenPayload)
65-
throw new Error('Failed to parse token payload')
63+
if (!tokenPayload || !tokenPayload.clientId || !tokenPayload.companyId) {
64+
return <InvalidToken />
6665
}
66+
6767
if (getPreviewMode(tokenPayload)) {
6868
return <NoPreviewSupport />
6969
}
70-
if (!tokenPayload.clientId || !tokenPayload.companyId) {
71-
console.info('Missing clientId or companyId in token payload', tokenPayload)
72-
throw new Error('Failed to parse token payload')
73-
}
7470

75-
const clientId = z.string().uuid().parse(tokenPayload.clientId)
71+
const clientId = z.string().uuid().safeParse(tokenPayload.clientId)
72+
if (!clientId.success) {
73+
return <InvalidToken />
74+
}
7675

7776
let settings: ISettings = {
7877
content: defaultState,
@@ -94,7 +93,7 @@ export default async function ClientPreviewPage({
9493
await Promise.all([
9594
getSettings(token),
9695
getCustomFields(searchParams.token),
97-
getClient(clientId, token),
96+
getClient(clientId.data, token),
9897
copilotClient.getWorkspaceInfo(),
9998
])
10099

0 commit comments

Comments
 (0)