fix(simulation): add FileNotFoundError check in delete_agent_profile and endpoint

This commit is contained in:
Ubuntu 2026-05-03 21:44:55 +00:00
parent 83cf890c83
commit ed71afe442
2 changed files with 5 additions and 0 deletions

View File

@ -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:

View File

@ -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)