Browse Source

fix: support both internal ID and custom ID in shop Qdrant endpoints

Fixed shop lookup in newly implemented endpoints to accept both:
- Internal database ID (e.g., f3d87e07-cf23-493e-bfcd-ef7f303548d1)
- Custom MCP ID (e.g., cf1a0652-d4cd-4e6f-85a0-87d203578c35)

Changes:
- Updated getShopQdrantInfo() to try getShopById() first, then getShopByCustomId()
- Updated getShopQdrantEmbeddings() with dual ID lookup
- Updated getShopQdrantErrorsNew() with dual ID lookup
- Updated scheduleShopDeletion() with dual ID lookup
- Fixed collection_name to use shop.custom_id instead of shopId param

This resolves the "Shop not found" errors when frontend passes internal
shop IDs to the Qdrant endpoints. Now both ID formats work correctly.

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

Co-Authored-By: Claude <noreply@anthropic.com>
Fszontagh 8 months ago
parent
commit
2fff451194
1 changed files with 21 additions and 9 deletions
  1. 21 9
      src/api/components/QdrantEndpoint.ts

+ 21 - 9
src/api/components/QdrantEndpoint.ts

@@ -812,8 +812,11 @@ export class QdrantEndpoint extends BaseEndpointComponent {
     try {
       const { shopId } = req.params;
 
-      // Get shop from database
-      const shop = this.db.getShopByCustomId(shopId);
+      // Get shop from database - try both internal ID and custom ID
+      let shop = this.db.getShopById(shopId);
+      if (!shop) {
+        shop = this.db.getShopByCustomId(shopId);
+      }
       if (!shop) {
         res.status(404).json({ error: 'Shop not found' });
         return;
@@ -845,8 +848,11 @@ export class QdrantEndpoint extends BaseEndpointComponent {
     try {
       const { shopId } = req.params;
 
-      // Get shop from database
-      const shop = this.db.getShopByCustomId(shopId);
+      // Get shop from database - try both internal ID and custom ID
+      let shop = this.db.getShopById(shopId);
+      if (!shop) {
+        shop = this.db.getShopByCustomId(shopId);
+      }
       if (!shop) {
         res.status(404).json({ error: 'Shop not found' });
         return;
@@ -860,7 +866,7 @@ export class QdrantEndpoint extends BaseEndpointComponent {
           embeddings: embeddings.map(embedding => ({
             id: `emb-${embedding.id}`,
             shop_content_id: `content-${embedding.id}`,
-            collection_name: `${shopId}-${embedding.content_type}_1`,
+            collection_name: shop.custom_id ? `${shop.custom_id}-${embedding.content_type}_1` : null,
             point_id: embedding.qdrant_point_id || null,
             embedding_status: embedding.embedding_status || 'pending',
             created_at: embedding.created_at,
@@ -879,8 +885,11 @@ export class QdrantEndpoint extends BaseEndpointComponent {
     try {
       const { shopId } = req.params;
 
-      // Get shop from database
-      const shop = this.db.getShopByCustomId(shopId);
+      // Get shop from database - try both internal ID and custom ID
+      let shop = this.db.getShopById(shopId);
+      if (!shop) {
+        shop = this.db.getShopByCustomId(shopId);
+      }
       if (!shop) {
         res.status(404).json({ error: 'Shop not found' });
         return;
@@ -928,8 +937,11 @@ export class QdrantEndpoint extends BaseEndpointComponent {
     try {
       const { shopId } = req.params;
 
-      // Get shop from database
-      const shop = this.db.getShopByCustomId(shopId);
+      // Get shop from database - try both internal ID and custom ID
+      let shop = this.db.getShopById(shopId);
+      if (!shop) {
+        shop = this.db.getShopByCustomId(shopId);
+      }
       if (!shop) {
         res.status(404).json({ error: 'Shop not found' });
         return;