Spaces:
Running

axeronis commited on
Commit
5097468
·
1 Parent(s): 031be0c

fix(products): fix 500 error by passing correct Tenant object to memory invalidation and add trailing slashes to frontend calls

Browse files
Files changed (2) hide show
  1. backend/app/api/products.py +10 -3
  2. frontend/lib/api.ts +1 -1
backend/app/api/products.py CHANGED
@@ -11,6 +11,7 @@ from app.models.user import User
11
  from app.api.deps import get_current_user
12
  from app.services.ai_memory_manager import get_memory_manager
13
  from pydantic import BaseModel
 
14
 
15
  router = APIRouter(prefix="/products", tags=["Products"])
16
 
@@ -96,7 +97,9 @@ async def create_product(
96
  await session.refresh(product)
97
 
98
  # SIGNAL: Invalidate AI Memory
99
- await get_memory_manager().invalidate_memory(session, current_user.tenant_id)
 
 
100
 
101
  return product
102
 
@@ -161,7 +164,9 @@ async def update_product(
161
  await session.refresh(product)
162
 
163
  # SIGNAL: Invalidate AI Memory
164
- await get_memory_manager().invalidate_memory(session, current_user.tenant_id)
 
 
165
 
166
  return product
167
 
@@ -192,7 +197,9 @@ async def delete_product(
192
  await session.commit()
193
 
194
  # SIGNAL: Invalidate AI Memory
195
- await get_memory_manager().invalidate_memory(session, current_user.tenant_id)
 
 
196
 
197
  return None
198
 
 
11
  from app.api.deps import get_current_user
12
  from app.services.ai_memory_manager import get_memory_manager
13
  from pydantic import BaseModel
14
+ from app.models.tenant import Tenant
15
 
16
  router = APIRouter(prefix="/products", tags=["Products"])
17
 
 
97
  await session.refresh(product)
98
 
99
  # SIGNAL: Invalidate AI Memory
100
+ tenant = await session.get(Tenant, current_user.tenant_id)
101
+ if tenant:
102
+ await get_memory_manager().invalidate_memory(session, tenant)
103
 
104
  return product
105
 
 
164
  await session.refresh(product)
165
 
166
  # SIGNAL: Invalidate AI Memory
167
+ tenant = await session.get(Tenant, current_user.tenant_id)
168
+ if tenant:
169
+ await get_memory_manager().invalidate_memory(session, tenant)
170
 
171
  return product
172
 
 
197
  await session.commit()
198
 
199
  # SIGNAL: Invalidate AI Memory
200
+ tenant = await session.get(Tenant, current_user.tenant_id)
201
+ if tenant:
202
+ await get_memory_manager().invalidate_memory(session, tenant)
203
 
204
  return None
205
 
frontend/lib/api.ts CHANGED
@@ -433,7 +433,7 @@ export const productsApi = {
433
  },
434
 
435
  createProduct: async (data: any) => {
436
- const response = await api.post('/api/v1/products', data)
437
  return response.data
438
  },
439
 
 
433
  },
434
 
435
  createProduct: async (data: any) => {
436
+ const response = await api.post('/api/v1/products/', data)
437
  return response.data
438
  },
439