Fix /api/overlay/data 500 error - add null checks for db_manager

- Check if api_bp.db_manager is available before accessing it
- Return overlay_data gracefully if database not available
parent a63cf4e8
...@@ -10747,6 +10747,9 @@ def get_overlay_data(): ...@@ -10747,6 +10747,9 @@ def get_overlay_data():
if headless_player.result_data and headless_player.result_data.get('match_id'): if headless_player.result_data and headless_player.result_data.get('match_id'):
try: try:
from ..database.models import MatchModel from ..database.models import MatchModel
if not api_bp.db_manager:
logger.warning("Database manager not available for overlay data")
return jsonify(overlay_data)
session = api_bp.db_manager.get_session() session = api_bp.db_manager.get_session()
try: try:
match = session.query(MatchModel).filter_by(id=headless_player.result_data['match_id']).first() match = session.query(MatchModel).filter_by(id=headless_player.result_data['match_id']).first()
...@@ -10804,6 +10807,9 @@ def get_overlay_data(): ...@@ -10804,6 +10807,9 @@ def get_overlay_data():
if current_phase == 'match' and current_match_id: if current_phase == 'match' and current_match_id:
try: try:
from ..database.models import MatchModel from ..database.models import MatchModel
if not api_bp.db_manager:
logger.warning("Database manager not available for match phase data")
return jsonify(overlay_data)
session = api_bp.db_manager.get_session() session = api_bp.db_manager.get_session()
try: try:
match = session.query(MatchModel).filter_by(id=current_match_id).first() match = session.query(MatchModel).filter_by(id=current_match_id).first()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment