From 805bfd04e3915bfce9bb44d45385e085c6a3676c Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Fri, 29 May 2026 16:39:39 +0530 Subject: [PATCH] fix: handle partial success in embedding generation by filling missing results with errors --- .../Databases/Http/VectorsDB/Embeddings/Text/Create.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Embeddings/Text/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Embeddings/Text/Create.php index 41fafd8460..05512e3151 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Embeddings/Text/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Embeddings/Text/Create.php @@ -105,6 +105,14 @@ class Create extends CreateDocumentAction foreach ($embedResult['embeddings'] as $embedding) { $results[] = $this->embeddingResult($model, $dimension, $embedding); } + + // Partial success: backend returned fewer embeddings than inputs. + // Fill the gap with error results so the response stays 1:1 with texts. + $missing = \count($batch) - \count($embedResult['embeddings']); + for ($i = 0; $i < $missing; $i++) { + $totalErrors++; + $results[] = $this->embeddingResult($model, $dimension, [], 'Error while generating embedding'); + } } catch (\Exception $e) { $totalErrors += \count($batch); $this->logError($e, $model, $project, $log, $logger);