Skip to content

Commit

Permalink
Fixed another rare migration bug from Alta's end.
Browse files Browse the repository at this point in the history
After ~50 days consecutively of running a bot with py-tale, it crashed with this error:

`{'id': 26, 'event': 'response', 'key': 'GET /ws/migrate', 'content': '{"message":"IDX20803: Unable to obtain configuration from: \'System.String\'.","error_code":"None"}', 'responseCode': 403}`

I believe this is either due to a bug or crash on Alta's end. In this new version of py-tale I've created a generic check to ensure the response code is `200` and if not, perform a manual migration just like it would if the response took too long from the last update of py-tale.
  • Loading branch information
dly2424 authored Apr 26, 2022
1 parent f091a00 commit 54adcc0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion py_tale.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,14 @@ async def run_ws(self):
var = json.loads(var) #Implement unsubscribing on old websocket? Maybe next verison, I don't think it's an issue.
if "key" in var:
if var["key"] == "GET /ws/migrate":
self.migrate_token = var["content"]
try:
if int(var["responseCode"]) == 200:
self.migrate_token = var["content"]
else:
print(Fore.RED + "Error in migrate response: Ignoring new key. I will perform a manual migrate instead. (non-200 response code)", end=Style.RESET_ALL + "\n")
except Exception as e:
if self.debug:
print(Fore.RED + f"Error in migrate response: Ignoring new key. I will perform a manual migrate instead. ({e})", end=Style.RESET_ALL + "\n")
if self.ws is websocket: #Only listen to subscriptions if the websocket is the latest websocket. Safety check for preventing double subscriptions if migrate fails while two websockets are open.
if "id" in var and "event" in var:
if var["event"] == "response" and int(var["id"]) in self.websocket_responses:
Expand Down

0 comments on commit 54adcc0

Please sign in to comment.