Skip to content

Commit 952399a

Browse files
Bill Leoutsakoscursoragent
authored andcommitted
fix(instagram): validate client ID before creating connect draft
Avoid orphan pending credential drafts when INSTAGRAM_CLIENT_ID is missing, matching the Shopify authorize ordering. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 30de5b1 commit 952399a

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

  • apps/sim/app/api/auth/instagram/authorize

apps/sim/app/api/auth/instagram/authorize/route.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ export const GET = withRouteHandler(async (request: NextRequest) => {
2828
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
2929
}
3030

31+
const clientId = env.INSTAGRAM_CLIENT_ID
32+
if (!clientId) {
33+
logger.error('INSTAGRAM_CLIENT_ID not configured')
34+
return NextResponse.json({ error: 'Instagram client ID not configured' }, { status: 500 })
35+
}
36+
3137
const parsed = await parseRequest(authorizeInstagramContract, request, {})
3238
if (!parsed.success) return parsed.response
3339
const { returnUrl, workspaceId } = parsed.data.query
@@ -44,12 +50,6 @@ export const GET = withRouteHandler(async (request: NextRequest) => {
4450
})
4551
}
4652

47-
const clientId = env.INSTAGRAM_CLIENT_ID
48-
if (!clientId) {
49-
logger.error('INSTAGRAM_CLIENT_ID not configured')
50-
return NextResponse.json({ error: 'Instagram client ID not configured' }, { status: 500 })
51-
}
52-
5353
const baseUrl = getBaseUrl()
5454
const state = generateShortId(32)
5555
const redirectUri = `${baseUrl}/api/auth/oauth2/callback/instagram`

0 commit comments

Comments
 (0)