Skip to content

Commit 3beb18b

Browse files
author
aadamgough
committed
fixed critical issues
1 parent ff1af41 commit 3beb18b

File tree

3 files changed

+86
-12
lines changed

3 files changed

+86
-12
lines changed

apps/sim/app/api/auth/oauth/utils.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export async function getOAuthToken(userId: string, providerId: string): Promise
173173
providerId,
174174
userId,
175175
})
176-
throw error
176+
return null
177177
}
178178
}
179179

@@ -255,15 +255,14 @@ export async function refreshAccessTokenIfNeeded(
255255
logger.info(`[${requestId}] Successfully refreshed access token for credential`)
256256
return refreshedToken.accessToken
257257
} catch (error) {
258-
// Re-throw the error to propagate detailed error messages (e.g., session expiry instructions)
259258
logger.error(`[${requestId}] Error refreshing token for credential`, {
260259
error: error instanceof Error ? error.message : String(error),
261260
stack: error instanceof Error ? error.stack : undefined,
262261
providerId: credential.providerId,
263262
credentialId,
264263
userId: credential.userId,
265264
})
266-
throw error
265+
return null
267266
}
268267
} else if (!accessToken) {
269268
// We have no access token and either no refresh token or not eligible to refresh
@@ -299,8 +298,8 @@ export async function refreshTokenIfNeeded(
299298
const refreshResult = await refreshOAuthToken(credential.providerId, credential.refreshToken!)
300299

301300
if (!refreshResult) {
302-
logger.error(`[${requestId}] Failed to refresh token for credential - no result returned`)
303-
throw new Error('Failed to refresh token: no result returned from provider')
301+
logger.error(`[${requestId}] Failed to refresh token for credential`)
302+
throw new Error('Failed to refresh token')
304303
}
305304

306305
const { accessToken: refreshedToken, expiresIn, refreshToken: newRefreshToken } = refreshResult

apps/sim/blocks/blocks/google_vault.ts

Lines changed: 82 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,62 @@ Return ONLY the hold name - no explanations, no quotes, no extra text.`,
159159
placeholder: 'Org Unit ID (alternative to emails)',
160160
condition: { field: 'operation', value: ['create_matters_holds', 'create_matters_export'] },
161161
},
162-
// Date filtering for exports and holds (holds only support MAIL and GROUPS corpus)
162+
// Date filtering for exports (works with all corpus types)
163163
{
164164
id: 'startTime',
165165
title: 'Start Time',
166166
type: 'short-input',
167167
placeholder: 'YYYY-MM-DDTHH:mm:ssZ',
168-
condition: { field: 'operation', value: ['create_matters_export', 'create_matters_holds'] },
168+
condition: { field: 'operation', value: 'create_matters_export' },
169+
wandConfig: {
170+
enabled: true,
171+
prompt: `Generate an ISO 8601 timestamp in GMT based on the user's description for Google Vault date filtering.
172+
The timestamp should be in the format: YYYY-MM-DDTHH:mm:ssZ (UTC timezone).
173+
Note: Google Vault rounds times to 12 AM on the specified date.
174+
Examples:
175+
- "yesterday" -> Calculate yesterday's date at 00:00:00Z
176+
- "last week" -> Calculate 7 days ago at 00:00:00Z
177+
- "beginning of this month" -> Calculate the 1st of current month at 00:00:00Z
178+
- "January 1, 2024" -> 2024-01-01T00:00:00Z
179+
180+
Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
181+
placeholder: 'Describe the start date (e.g., "last month", "January 1, 2024")...',
182+
generationType: 'timestamp',
183+
},
184+
},
185+
{
186+
id: 'endTime',
187+
title: 'End Time',
188+
type: 'short-input',
189+
placeholder: 'YYYY-MM-DDTHH:mm:ssZ',
190+
condition: { field: 'operation', value: 'create_matters_export' },
191+
wandConfig: {
192+
enabled: true,
193+
prompt: `Generate an ISO 8601 timestamp in GMT based on the user's description for Google Vault date filtering.
194+
The timestamp should be in the format: YYYY-MM-DDTHH:mm:ssZ (UTC timezone).
195+
Note: Google Vault rounds times to 12 AM on the specified date.
196+
Examples:
197+
- "now" -> Current timestamp
198+
- "today" -> Today's date at 23:59:59Z
199+
- "end of last month" -> Last day of previous month at 23:59:59Z
200+
- "December 31, 2024" -> 2024-12-31T23:59:59Z
201+
202+
Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
203+
placeholder: 'Describe the end date (e.g., "today", "end of last quarter")...',
204+
generationType: 'timestamp',
205+
},
206+
},
207+
// Date filtering for holds (only works with MAIL and GROUPS corpus)
208+
{
209+
id: 'startTime',
210+
title: 'Start Time',
211+
type: 'short-input',
212+
placeholder: 'YYYY-MM-DDTHH:mm:ssZ',
213+
condition: {
214+
field: 'operation',
215+
value: 'create_matters_holds',
216+
and: { field: 'corpus', value: ['MAIL', 'GROUPS'] },
217+
},
169218
wandConfig: {
170219
enabled: true,
171220
prompt: `Generate an ISO 8601 timestamp in GMT based on the user's description for Google Vault date filtering.
@@ -187,7 +236,11 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
187236
title: 'End Time',
188237
type: 'short-input',
189238
placeholder: 'YYYY-MM-DDTHH:mm:ssZ',
190-
condition: { field: 'operation', value: ['create_matters_export', 'create_matters_holds'] },
239+
condition: {
240+
field: 'operation',
241+
value: 'create_matters_holds',
242+
and: { field: 'corpus', value: ['MAIL', 'GROUPS'] },
243+
},
191244
wandConfig: {
192245
enabled: true,
193246
prompt: `Generate an ISO 8601 timestamp in GMT based on the user's description for Google Vault date filtering.
@@ -204,12 +257,13 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
204257
generationType: 'timestamp',
205258
},
206259
},
260+
// Search terms for exports (works with all corpus types)
207261
{
208262
id: 'terms',
209263
title: 'Search Terms',
210264
type: 'long-input',
211265
placeholder: 'Enter search query (e.g., from:user@example.com subject:confidential)',
212-
condition: { field: 'operation', value: ['create_matters_export', 'create_matters_holds'] },
266+
condition: { field: 'operation', value: 'create_matters_export' },
213267
wandConfig: {
214268
enabled: true,
215269
prompt: `Generate a Google Vault search query based on the user's description.
@@ -226,7 +280,30 @@ For DRIVE corpus, use Drive search operators:
226280
- owner:user@example.com - files owned by user
227281
- type:document - specific file types
228282
229-
For holds, date filtering only works with MAIL and GROUPS corpus.
283+
Return ONLY the search query - no explanations, no quotes, no extra text.`,
284+
placeholder: 'Describe what content to search for...',
285+
},
286+
},
287+
// Search terms for holds (only works with MAIL and GROUPS corpus)
288+
{
289+
id: 'terms',
290+
title: 'Search Terms',
291+
type: 'long-input',
292+
placeholder: 'Enter search query (e.g., from:user@example.com subject:confidential)',
293+
condition: {
294+
field: 'operation',
295+
value: 'create_matters_holds',
296+
and: { field: 'corpus', value: ['MAIL', 'GROUPS'] },
297+
},
298+
wandConfig: {
299+
enabled: true,
300+
prompt: `Generate a Google Vault search query based on the user's description.
301+
The query can use Gmail-style search operators:
302+
- from:user@example.com - emails from specific sender
303+
- to:user@example.com - emails to specific recipient
304+
- subject:keyword - emails with keyword in subject
305+
- has:attachment - emails with attachments
306+
- filename:pdf - emails with PDF attachments
230307
231308
Return ONLY the search query - no explanations, no quotes, no extra text.`,
232309
placeholder: 'Describe what content to search for...',

apps/sim/lib/oauth/oauth.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,8 +1247,6 @@ export async function refreshOAuthToken(
12471247
}
12481248
} catch (error) {
12491249
logger.error('Error refreshing token:', { error })
1250-
// Re-throw specific errors so they propagate with their detailed messages
1251-
// Only return null for truly unexpected errors without useful messages
12521250
throw error
12531251
}
12541252
}

0 commit comments

Comments
 (0)