Skip to content

Commit

Permalink
Add try/catch in remove_sid
Browse files Browse the repository at this point in the history
When a user did not create faraday's database and run a faraday-manage command triggers an operational error.
  • Loading branch information
Diego Nadares committed Mar 13, 2024
1 parent 70c3cf1 commit 5285c91
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion faraday/server/websockets/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

# Related third party imports
import itsdangerous
import sqlalchemy
from flask import current_app, request

from faraday.server.api.modules.websocket_auth import decode_agent_websocket_token
Expand Down Expand Up @@ -48,7 +49,11 @@ def update_executors(agent, executors):


def remove_sid():
agents = Agent.query.filter(Agent.sid!=None).all() # noqa E711
try:
agents = Agent.query.filter(Agent.sid!=None).all() # noqa E711
except sqlalchemy.exc.OperationalError as error:
logger.warning("Could not update agents table. %s", error)
return
logger.debug(f"Found {len(agents)} agents connected")
for agent in agents:
agent.sid = None
Expand Down

0 comments on commit 5285c91

Please sign in to comment.