File tree Expand file tree Collapse file tree 3 files changed +17
-4
lines changed
Expand file tree Collapse file tree 3 files changed +17
-4
lines changed Original file line number Diff line number Diff line change 77 IntegrationListResponse ,
88 IntegrationStatusResponse
99)
10- from app .services .integration_service import integration_service
10+ from app .services .integration_service import integration_service , IntegrationNotFoundError
1111from app .core .dependencies import get_current_user
1212
1313router = APIRouter ()
@@ -76,8 +76,10 @@ async def update_integration(
7676 """Update an existing integration."""
7777 try :
7878 return await integration_service .update_integration (user_id , integration_id , request )
79- except ValueError as e :
79+ except IntegrationNotFoundError as e :
8080 raise HTTPException (status_code = status .HTTP_404_NOT_FOUND , detail = str (e )) from e
81+ except ValueError as e :
82+ raise HTTPException (status_code = status .HTTP_400_BAD_REQUEST , detail = str (e )) from e
8183 except HTTPException :
8284 raise
8385 except Exception as e :
@@ -95,6 +97,7 @@ async def delete_integration(
9597 try :
9698 await integration_service .delete_integration (user_id , integration_id )
9799 except ValueError as e :
100+ # For delete operation, ValueError means "not found"
98101 raise HTTPException (status_code = status .HTTP_404_NOT_FOUND , detail = str (e )) from e
99102 except HTTPException :
100103 raise
Original file line number Diff line number Diff line change 1313logger = logging .getLogger (__name__ )
1414
1515
16+ class IntegrationNotFoundError (Exception ):
17+ """Raised when an integration is not found."""
18+ pass
19+
20+
1621class IntegrationService :
1722 """Service for registering organizations (stores org info only)."""
1823
@@ -142,7 +147,7 @@ async def update_integration(
142147
143148 existing = await self .get_integration (user_id , integration_id )
144149 if not existing :
145- raise ValueError ("Integration not found" )
150+ raise IntegrationNotFoundError ("Integration not found" )
146151
147152 if request .organization_link is not None :
148153 base_config = (update_data .get ("config" ) or existing .config or {}).copy ()
@@ -169,6 +174,11 @@ async def update_integration(
169174 async def delete_integration (self , user_id : UUID , integration_id : UUID ) -> bool :
170175 """Delete an integration."""
171176 try :
177+ # Check if integration exists before deleting
178+ existing = await self .get_integration (user_id , integration_id )
179+ if not existing :
180+ raise ValueError ("Integration not found" )
181+
172182 await self .supabase .table ("organization_integrations" )\
173183 .delete ()\
174184 .eq ("id" , str (integration_id ))\
Original file line number Diff line number Diff line change @@ -224,7 +224,7 @@ watchfiles==1.0.5
224224wcwidth == 0.2.13
225225weaviate-client == 4.15.4
226226websocket-client == 1.8.0
227- websockets >= 14.2 , < 15 .0
227+ websockets >= 15.0.1 , < 16.0 .0
228228wrapt == 1.17.2
229229xxhash == 3.5.0
230230yarl == 1.20.1
You can’t perform that action at this time.
0 commit comments