Skip to content

Commit 00c66d4

Browse files
committed
improvement(persona): reject unexpected import response bodies instead of returning an empty importer
1 parent 2acc72e commit 00c66d4

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

  • apps/sim/app/api/tools/persona/import-accounts

apps/sim/app/api/tools/persona/import-accounts/route.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,25 @@ export const POST = withRouteHandler(async (request: NextRequest) => {
9595
)
9696
}
9797

98+
const importer = mapImporter(personaData?.data ?? {})
99+
if (!importer.id) {
100+
logger.error(`[${requestId}] Persona import accounts returned an unexpected response body`, {
101+
status: personaResponse.status,
102+
})
103+
return NextResponse.json(
104+
{ success: false, error: 'Persona returned an unexpected response for the account import' },
105+
{ status: 502 }
106+
)
107+
}
108+
98109
logger.info(`[${requestId}] Persona account import created`, {
99-
importerId: personaData?.data?.id,
110+
importerId: importer.id,
100111
})
101112

102113
return NextResponse.json({
103114
success: true,
104115
output: {
105-
importer: mapImporter(personaData?.data ?? {}),
116+
importer,
106117
},
107118
})
108119
} catch (error) {

0 commit comments

Comments
 (0)