Skip to content

Commit 1fee00a

Browse files
author
aadamgough
committed
restore error thorwing
1 parent 3beb18b commit 1fee00a

File tree

3 files changed

+7
-41
lines changed

3 files changed

+7
-41
lines changed

apps/sim/app/api/auth/oauth/token/route.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,8 @@ export async function POST(request: NextRequest) {
129129
{ status: 200 }
130130
)
131131
} catch (error) {
132-
const errorMessage = error instanceof Error ? error.message : 'Failed to refresh access token'
133-
logger.error(`[${requestId}] Failed to refresh access token:`, {
134-
error: errorMessage,
135-
stack: error instanceof Error ? error.stack : undefined,
136-
})
137-
return NextResponse.json({ error: errorMessage }, { status: 401 })
132+
logger.error(`[${requestId}] Failed to refresh access token:`, error)
133+
return NextResponse.json({ error: 'Failed to refresh access token' }, { status: 401 })
138134
}
139135
} catch (error) {
140136
logger.error(`[${requestId}] Error getting access token`, error)
@@ -211,13 +207,8 @@ export async function GET(request: NextRequest) {
211207
},
212208
{ status: 200 }
213209
)
214-
} catch (error) {
215-
const errorMessage = error instanceof Error ? error.message : 'Failed to refresh access token'
216-
logger.error(`[${requestId}] Failed to refresh access token:`, {
217-
error: errorMessage,
218-
stack: error instanceof Error ? error.stack : undefined,
219-
})
220-
return NextResponse.json({ error: errorMessage }, { status: 401 })
210+
} catch (_error) {
211+
return NextResponse.json({ error: 'Failed to refresh access token' }, { status: 401 })
221212
}
222213
} catch (error) {
223214
logger.error(`[${requestId}] Error fetching access token`, error)

apps/sim/lib/oauth/oauth.ts

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,7 @@ export async function refreshOAuthToken(
11711171

11721172
if (!response.ok) {
11731173
const errorText = await response.text()
1174-
let errorData: any = errorText
1174+
let errorData = errorText
11751175

11761176
try {
11771177
errorData = JSON.parse(errorText)
@@ -1191,29 +1191,6 @@ export async function refreshOAuthToken(
11911191
hasRefreshToken: !!refreshToken,
11921192
refreshTokenPrefix: refreshToken ? `${refreshToken.substring(0, 10)}...` : 'none',
11931193
})
1194-
1195-
// Check for Google Workspace session control errors (RAPT - Reauthentication Policy Token)
1196-
// This occurs when the organization enforces periodic re-authentication
1197-
if (
1198-
typeof errorData === 'object' &&
1199-
(errorData.error_subtype === 'invalid_rapt' ||
1200-
errorData.error_description?.includes('reauth related error'))
1201-
) {
1202-
throw new Error(
1203-
`Session expired due to organization security policy. Please reconnect your ${providerId} account to continue. Alternatively, ask your Google Workspace admin to exempt this app from session control: Admin Console → Security → Google Cloud session control → "Exempt trusted apps".`
1204-
)
1205-
}
1206-
1207-
if (
1208-
typeof errorData === 'object' &&
1209-
errorData.error === 'invalid_grant' &&
1210-
!errorData.error_subtype
1211-
) {
1212-
throw new Error(
1213-
`Access has been revoked or the refresh token is no longer valid. Please reconnect your ${providerId} account.`
1214-
)
1215-
}
1216-
12171194
throw new Error(`Failed to refresh token: ${response.status} ${errorText}`)
12181195
}
12191196

@@ -1247,6 +1224,6 @@ export async function refreshOAuthToken(
12471224
}
12481225
} catch (error) {
12491226
logger.error('Error refreshing token:', { error })
1250-
throw error
1227+
return null
12511228
}
12521229
}

apps/sim/tools/google_vault/types.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,11 @@ export type GoogleVaultCorpus = 'MAIL' | 'DRIVE' | 'GROUPS' | 'HANGOUTS_CHAT' |
3636
export interface GoogleVaultCreateMattersHoldsParams extends GoogleVaultCommonParams {
3737
holdName: string
3838
corpus: GoogleVaultCorpus
39-
accountEmails?: string // Comma-separated list or array handled in the tool
39+
accountEmails?: string
4040
orgUnitId?: string
41-
// Query parameters for MAIL and GROUPS corpus (date filtering)
4241
terms?: string
4342
startTime?: string
4443
endTime?: string
45-
// Drive-specific option
4644
includeSharedDrives?: boolean
4745
}
4846

0 commit comments

Comments
 (0)