From e2ed026ee422de9075eb878eb193de509f13b7ec Mon Sep 17 00:00:00 2001 From: taylanbakircioglu Date: Tue, 7 Apr 2026 14:35:47 +0300 Subject: [PATCH] fix: clear stale gadget warnings when analysis is restarted When an analysis is stopped and restarted, the previous run's gadget_errors and has_gadget_warnings were persisted in output_config and never cleared, causing a false "Some gadgets failed to start" warning in the UI even when all gadgets started successfully. Made-with: Cursor --- services/analysis-orchestrator/app/grpc_server.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/services/analysis-orchestrator/app/grpc_server.py b/services/analysis-orchestrator/app/grpc_server.py index cc8bd58..7072645 100644 --- a/services/analysis-orchestrator/app/grpc_server.py +++ b/services/analysis-orchestrator/app/grpc_server.py @@ -439,7 +439,15 @@ class AnalysisOrchestratorService(analysis_orchestrator_pb2_grpc.AnalysisOrchest # Update auto-stop monitor with current sessions auto_stop_monitor.set_active_sessions(self.active_sessions) - # Update analysis status (sync) + # Clear stale gadget warnings from previous runs before setting status + clean_output = dict(analysis.output_config or {}) + clean_output.pop("gadget_errors", None) + clean_output.pop("has_gadget_warnings", None) + db_manager.update_analysis_sync(request.analysis_id, { + "output_config": clean_output + }) + + # Update analysis status (sets started_at timestamp) db_manager.update_analysis_status_sync(request.analysis_id, AnalysisStatus.RUNNING) # Check for gadget startup errors ASYNCHRONOUSLY (non-blocking) @@ -477,7 +485,7 @@ class AnalysisOrchestratorService(analysis_orchestrator_pb2_grpc.AnalysisOrchest logger.error(f"Background gadget error check failed: {e}") # Start background thread (non-blocking) - existing_output = analysis.output_config or {} + existing_output = clean_output thread = threading.Thread( target=_check_gadget_errors_background, args=(request.analysis_id, list(session_ids), existing_output),