fix: agent delete proceeds even when upstream services error (#867)
* fix: agent delete proceeds even when upstream services error Two stacked issues caused DELETE /api/agents/{id}/delete to 500 and leave agents stuck in CoPilot's DB: 1. ensure_client_deleted (post-delete verification step in delete_agent_velociraptor) used the artifact "Server.Information.Clients", which doesn't exist on Velociraptor 0.75.6. The query returned `None`, then `.get("flow_id")` on `None` crashed: 'NoneType' object has no attribute 'get' The actual delete had already succeeded — the verification was redundant (delete_client raises on failure on its own) and Velociraptor's eventual consistency made the poll flaky regardless. Drop ensure_client_deleted and the now-unused check_client_in_results. 2. The delete route ran Wazuh → Velociraptor → CoPilot DB sequentially with no error isolation. Any upstream failure (Velociraptor down, client already gone, server-side bug) blocked the CoPilot bookkeeping delete. Wrap each upstream step in try/except, log the failure, append to upstream_errors, and always proceed to the DB delete. Successful responses surface upstream issues in the message but don't fail the request. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix: remove unnecessary blank lines in delete_client function --------- Co-authored-by: taylor_socfortress <taylor.walton@socfortress.co> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>