瀏覽代碼

fix: add vector validation in shoprenter-sync to prevent missing vector error

- Add validation for existingPoint.vector before reusing embeddings
- Treat points with missing/invalid vectors as needing new embeddings
- Prevents Qdrant API error "missing field vector" during sync operations
- Ensures excluded products are properly handled without sync failures

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Fszontagh 4 月之前
父節點
當前提交
7ba8e0fdbe
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      supabase/functions/shoprenter-sync/index.ts

+ 2 - 1
supabase/functions/shoprenter-sync/index.ts

@@ -255,7 +255,8 @@ async function syncProductsToQdrant(
       const productId = product.innerId.toString()
       const productId = product.innerId.toString()
       const existingPoint = existingProductsMap.get(productId)
       const existingPoint = existingProductsMap.get(productId)
 
 
-      if (hasProductChanged(product, existingPoint)) {
+      // Check if product needs new embedding (changed OR missing/invalid vector)
+      if (hasProductChanged(product, existingPoint) || !existingPoint?.vector || !Array.isArray(existingPoint.vector)) {
         productsNeedingEmbedding.push(product)
         productsNeedingEmbedding.push(product)
       } else {
       } else {
         productsToReuse.push({ product, existingPoint })
         productsToReuse.push({ product, existingPoint })