Skip to content

Commit f4e1f28

Browse files
committed
fix(uploads): set kb presignedEndpoint fallback; race-safe blob HEAD
1 parent 639fe18 commit f4e1f28

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

apps/sim/app/workspace/[workspaceId]/knowledge/hooks/use-knowledge-upload.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ export function useKnowledgeUpload(options: UseKnowledgeUploadOptions = {}) {
257257
file,
258258
workspaceId: options.workspaceId,
259259
context: 'knowledge-base',
260+
presignedEndpoint: '/api/files/presigned',
260261
presignedOverride: presigned,
261262
onProgress,
262263
})

apps/sim/lib/uploads/providers/blob/client.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -341,14 +341,19 @@ export async function headBlobObject(
341341
const containerClient = blobServiceClient.getContainerClient(containerName)
342342
const blockBlobClient = containerClient.getBlockBlobClient(key)
343343

344-
if (!(await blockBlobClient.exists())) {
345-
return null
346-
}
347-
348-
const properties = await blockBlobClient.getProperties()
349-
return {
350-
size: properties.contentLength ?? 0,
351-
contentType: properties.contentType,
344+
try {
345+
const properties = await blockBlobClient.getProperties()
346+
return {
347+
size: properties.contentLength ?? 0,
348+
contentType: properties.contentType,
349+
}
350+
} catch (err) {
351+
const status = (err as { statusCode?: number }).statusCode
352+
const code = (err as { code?: string }).code
353+
if (status === 404 || code === 'BlobNotFound') {
354+
return null
355+
}
356+
throw err
352357
}
353358
}
354359

0 commit comments

Comments
 (0)