@cryptotaxi247 / CoPilot / commits / 52017da9

Refactor artifact recommendation error handling

Taylor committed Jul 2, 2024 at 16:43 UTC 52017da979f587c8ef438678776692d0d65409d6
1 file changed +8 -1
backend/app/connectors/velociraptor/services/artifacts.py
+8 -1
@@ -301,5 +301,12 @@ async def post_to_copilot_ai_module(data: ArtifactReccomendationRequest) -> Arti
301 json=data.dict(),
302 timeout=120,
303 )
304 - logger.info(f"Response from copilot-ai-module: {data.json()}")
304 + response_data = data.json()
305 + logger.info(f"Response from copilot-ai-module: {response_data}")
306 +
307 + if not response_data.get('success'):
308 + raise HTTPException(
309 + status_code=400,
310 + detail=response_data.get('message', 'Request to copilot-ai-module was not successful'),
311 + )
312 return ArtifactReccomendationResponse(**data.json())