Skip to content

Commit 40f3b45

Browse files
committed
fix(google-drive): use status-based fallback instead of string matching for export errors
1 parent 108d4e0 commit 40f3b45

File tree

1 file changed

+5
-8
lines changed
  • apps/sim/app/api/tools/google_drive/download

1 file changed

+5
-8
lines changed

apps/sim/app/api/tools/google_drive/download/route.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,18 +143,15 @@ export async function POST(request: NextRequest) {
143143
.catch(() => ({}))) as GoogleApiErrorResponse
144144
const errorMessage = exportError.error?.message || ''
145145

146-
const hasCustomFormat = !!exportMimeType
147146
const defaultFormat = DEFAULT_EXPORT_FORMATS[fileMimeType]
148-
if (
149-
hasCustomFormat &&
150-
defaultFormat &&
151-
exportMimeType !== defaultFormat &&
152-
errorMessage.toLowerCase().includes('conversion')
153-
) {
154-
logger.warn(`[${requestId}] Export format not supported, falling back to default`, {
147+
const canFallback = !!exportMimeType && !!defaultFormat && exportMimeType !== defaultFormat
148+
149+
if (canFallback) {
150+
logger.warn(`[${requestId}] Export failed with custom format, falling back to default`, {
155151
requestedFormat: exportFormat,
156152
fallbackFormat: defaultFormat,
157153
fileMimeType,
154+
status: exportResponse.status,
158155
})
159156

160157
finalMimeType = defaultFormat

0 commit comments

Comments
 (0)