diff --git a/backend/app/api/simulation.py b/backend/app/api/simulation.py index f803a36f..64731222 100644 --- a/backend/app/api/simulation.py +++ b/backend/app/api/simulation.py @@ -2743,6 +2743,8 @@ def delete_agent(simulation_id: str, user_id: int): return jsonify({"success": False, "error": str(e)}), 403 except LookupError as e: return jsonify({"success": False, "error": str(e)}), 404 + except FileNotFoundError as e: + return jsonify({"success": False, "error": str(e)}), 404 return jsonify({"success": True, "data": {"deleted_user_id": user_id}}) except Exception as e: diff --git a/backend/app/services/simulation_manager.py b/backend/app/services/simulation_manager.py index fe769cc3..8fee0992 100644 --- a/backend/app/services/simulation_manager.py +++ b/backend/app/services/simulation_manager.py @@ -614,6 +614,9 @@ class SimulationManager: profiles_file = os.path.join(sim_dir, "reddit_profiles.json") backup_file = profiles_file + ".bak" + if not os.path.exists(profiles_file): + raise FileNotFoundError(f"reddit_profiles.json not found for {simulation_id}") + with open(profiles_file, 'r', encoding='utf-8') as f: profiles = json.load(f)