Skip to content

Commit 3dcdbe4

Browse files
authored
Fix issue with torchx status failing when return error is string instead of json
Differential Revision: D56338530 Pull Request resolved: #889
1 parent 5100b5d commit 3dcdbe4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

torchx/specs/api.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from dataclasses import asdict, dataclass, field
1414
from datetime import datetime
1515
from enum import Enum
16+
from json import JSONDecodeError
1617
from string import Template
1718
from typing import (
1819
Any,
@@ -554,7 +555,10 @@ def _format_error_message(self, msg: str, header: str, width: int = 80) -> str:
554555

555556
def _format_replica_status(self, replica_status: ReplicaStatus) -> str:
556557
if replica_status.structured_error_msg != NONE:
557-
error_data = json.loads(replica_status.structured_error_msg)
558+
try:
559+
error_data = json.loads(replica_status.structured_error_msg)
560+
except JSONDecodeError:
561+
return replica_status.structured_error_msg
558562
error_message = self._format_error_message(
559563
msg=error_data["message"]["message"], header=" error_msg: "
560564
)

0 commit comments

Comments
 (0)