diff --git a/src/spring/HISTORY.md b/src/spring/HISTORY.md index 78cc0c3189c..0280d94d553 100644 --- a/src/spring/HISTORY.md +++ b/src/spring/HISTORY.md @@ -1,5 +1,9 @@ Release History =============== +1.28.4 +--- +* Fix regression issue caused by the SDK change. + 1.28.3 --- * Update Azure Spring Apps reference doc. diff --git a/src/spring/azext_spring/_utils.py b/src/spring/azext_spring/_utils.py index 5e5e1d055f8..357828b2efa 100644 --- a/src/spring/azext_spring/_utils.py +++ b/src/spring/azext_spring/_utils.py @@ -4,6 +4,7 @@ # -------------------------------------------------------------------------------------------- import json import re +import xml.etree.ElementTree as ET from datetime import datetime from enum import Enum import os @@ -334,10 +335,32 @@ def handle_asc_exception(ex): try: raise CLIError(ex.inner_exception.error.message) except AttributeError: + logger.debug(f"CLIError ex: {ex}") + logger.debug(f"CLIError ex.response.internal_response.text: {ex.response.internal_response.text}") if hasattr(ex, 'response') and ex.response.internal_response.text: - response_dict = json.loads(ex.response.internal_response.text) - raise CLIError(response_dict["error"]["message"]) + logger.debug("CLIError: Trying to parse the exception message.") + try: + response_dict = json.loads(ex.response.internal_response.text) + logger.debug(f"CLIError response_dict: {response_dict}") + raise CLIError(response_dict["error"]["message"]) + except json.JSONDecodeError: + # Try to extract error from XML format + try: + root = ET.fromstring(ex.response.internal_response.text) + # Look for common error message patterns in XML + error_msg = root.find('.//Message') + if error_msg is not None and error_msg.text: + raise CLIError(error_msg.text) + # If no Message element, try to find any text content + error_text = ''.join(root.itertext()).strip() + if error_text: + raise CLIError(error_text) + except ET.ParseError: + pass + # If both JSON and XML parsing fail, return the raw text + raise CLIError(ex.response.internal_response.text) else: + logger.debug("CLIError: Unable to parse the exception message.") raise CLIError(ex) diff --git a/src/spring/setup.py b/src/spring/setup.py index 8133b8ba53c..63ba942acd0 100644 --- a/src/spring/setup.py +++ b/src/spring/setup.py @@ -16,7 +16,7 @@ # TODO: Confirm this is the right version number you want and it matches your # HISTORY.rst entry. -VERSION = '1.28.3' +VERSION = '1.28.4' # The full list of classifiers is available at # https://pypi.python.org/pypi?%3Aaction=list_classifiers