fix(copilot): fix image auth (#1841)

* Fix copilot image auth

* Lint

* Remove extra loggign

* Update apps/sim/app/api/copilot/chat/route.ts

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

---------

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
This commit is contained in:
Siddharth Ganesan
2025-11-07 11:40:13 -08:00
committed by GitHub
parent c3436e998f
commit a31dc733cf
3 changed files with 10 additions and 2 deletions

View File

@@ -325,6 +325,7 @@ export async function POST(req: NextRequest) {
...(processedFileContents.length > 0 && { fileAttachments: processedFileContents }),
}
try {
logger.info(`[${tracker.requestId}] About to call Sim Agent`, {
hasContext: agentContexts.length > 0,

View File

@@ -122,7 +122,7 @@ export async function verifyFileAccess(
}
// 2. Execution files: workspace_id/workflow_id/execution_id/filename
if (inferredContext === 'execution' || isExecutionFile(cloudKey, bucketType)) {
if (inferredContext === 'execution' || (!context && isExecutionFile(cloudKey, bucketType))) {
return await verifyExecutionFileAccess(cloudKey, userId, customConfig)
}

View File

@@ -245,6 +245,11 @@ export async function POST(request: NextRequest) {
logger.info(`Uploading ${context} file: ${originalName}`)
// Generate storage key with context prefix and timestamp to ensure uniqueness
const timestamp = Date.now()
const safeFileName = originalName.replace(/\s+/g, '-')
const storageKey = `${context}/${timestamp}-${safeFileName}`
const metadata: Record<string, string> = {
originalName: originalName,
uploadedAt: new Date().toISOString(),
@@ -258,9 +263,11 @@ export async function POST(request: NextRequest) {
const fileInfo = await storageService.uploadFile({
file: buffer,
fileName: originalName,
fileName: storageKey,
contentType: file.type,
context,
preserveKey: true,
customKey: storageKey,
metadata,
})