FlowiseAI/Flowise · error · Error

File ${fileName} not found

Error message

File ${fileName} not found

What it means

Re-thrown inside the catch block of the GCS file-read fallback path. After the primary object key is not found, the provider tries a legacy key layout (without orgId); if that fallback read also fails, the original/any error is swallowed and replaced with this explicit not-found message.

Source

Thrown at packages/components/src/storage/GCSStorageProvider.ts:232

                if (buffer) {
                    const file = this.bucket.file(filePath)
                    await new Promise<void>((resolve, reject) => {
                        file.createWriteStream()
                            .on('error', (err) => reject(err))
                            .on('finish', () => resolve())
                            .end(buffer)
                    })

                    // Delete the old file
                    await fallbackFile.delete()

                    // Check if the directory is empty and delete recursively if needed
                    await this.cleanEmptyGCSFolders(normalizedChatflowId)

                    return buffer
                }
            } catch (fallbackError) {
                throw new Error(`File ${fileName} not found`)
            }
        }
    }

    async getFilesListFromStorage(...paths: string[]): Promise<FileInfo[]> {
        const normalizedPaths = paths.map((p) => this.normalizePath(p))
        const prefix = normalizedPaths.join('/')

        const [files] = await this.bucket.getFiles({ prefix })

        return files.map((file) => ({
            name: file.name.split('/').pop() || '',
            path: file.name,
            size: typeof file.metadata.size === 'string' ? parseInt(file.metadata.size, 10) || 0 : file.metadata.size || 0
        }))
    }

    async removeFilesFromStorage(...paths: string[]): Promise<StorageSizeResult> {

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Verify the file exists in the bucket with the expected key (orgId/chatflowId/chatId/name and the legacy chatflowId/chatId/name).
  2. Return a 404 to the client and surface only the fileName, not internal key details.
  3. Re-upload or restore the object if it was deleted.

Example fix

// before
const buf = await provider.streamStorageFile(chatflowId, chatId, fileName, orgId)
// after
try {
  const buf = await provider.streamStorageFile(chatflowId, chatId, fileName, orgId)
} catch (e) {
  if (/not found/i.test(e.message)) return res.status(404).send('file not found')
  throw e
}
Defensive patterns

Strategy: try-catch

Validate before calling

async function gcsFileExists(bucket: Bucket, key: string): Promise<boolean> {
  const [exists] = await bucket.file(key).exists()
  return exists
}
// note: existence can change between check and read (TOCTOU); pair with try-catch

Type guard

function isNotFound(err: unknown): boolean {
  return err instanceof Error && /File .* not found/i.test(err.message)
}

Try / catch

try {
  const buf = await provider.streamStorageFile(chatflowId, chatId, fileName, orgId)
} catch (e) {
  if (e instanceof Error && /not found/i.test(e.message)) return res.status(404).send('file not found')
  throw e
}

Prevention

When it happens

Trigger: Requesting a file whose blob does not exist under either the orgId-scoped key or the legacy key layout. The throw is at GCSStorageProvider.ts:231 inside `catch (fallbackError)`.

Common situations: The file was deleted or never uploaded; the orgId migration left the blob under a different key; requesting a file immediately after upload before GCS consistency reflects it.

Related errors


AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12). Data as JSON: /api/errors/82d8c38deeda2972. Report an issue: GitHub.