@@ -23,7 +23,7 @@ import type { StorageContext } from '@/lib/uploads/config'
2323import { generateKnowledgeBaseFileKey } from '@/lib/uploads/contexts/knowledge-base/knowledge-base-file-manager'
2424import { generateWorkspaceFileKey } from '@/lib/uploads/contexts/workspace/workspace-file-manager'
2525import { MAX_WORKSPACE_FORMDATA_FILE_SIZE } from '@/lib/uploads/shared/types'
26- import { isImageFileType , resolveFileType } from '@/lib/uploads/utils/file-utils'
26+ import { isArchiveFileName , isImageFileType , resolveFileType } from '@/lib/uploads/utils/file-utils'
2727import {
2828 SUPPORTED_ATTACHMENT_EXTENSIONS ,
2929 SUPPORTED_IMAGE_EXTENSIONS ,
@@ -34,9 +34,12 @@ import { createErrorResponse, InvalidRequestError } from '@/app/api/files/utils'
3434
3535const ALLOWED_EXTENSIONS = new Set < string > ( SUPPORTED_ATTACHMENT_EXTENSIONS )
3636
37- function validateFileExtension ( filename : string ) : boolean {
37+ function validateFileExtension ( filename : string , context : StorageContext ) : boolean {
3838 const extension = filename . split ( '.' ) . pop ( ) ?. toLowerCase ( )
3939 if ( ! extension ) return false
40+ // Archives are only extractable in the mothership copilot flow; every other
41+ // context keeps rejecting them up front instead of failing downstream.
42+ if ( context === 'mothership' && isArchiveFileName ( filename ) ) return true
4043 return ALLOWED_EXTENSIONS . has ( extension )
4144}
4245
@@ -150,7 +153,7 @@ export const POST = withRouteHandler(async (request: NextRequest) => {
150153 for ( const file of files ) {
151154 const originalName = file . name || 'untitled.md'
152155
153- if ( ! validateFileExtension ( originalName ) ) {
156+ if ( ! validateFileExtension ( originalName , context ) ) {
154157 const extension = originalName . split ( '.' ) . pop ( ) ?. toLowerCase ( ) || 'unknown'
155158 throw new InvalidRequestError (
156159 `File type '${ extension } ' is not allowed. Allowed types: ${ Array . from ( ALLOWED_EXTENSIONS ) . join ( ', ' ) } `
0 commit comments