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
This commit is contained in:
taylanbakircioglu
2026-04-07 14:35:47 +03:00
parent 2549658596
commit e2ed026ee4
@@ -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),