Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/spring/HISTORY.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
27 changes: 25 additions & 2 deletions src/spring/azext_spring/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# --------------------------------------------------------------------------------------------
import json
import re
import xml.etree.ElementTree as ET
from datetime import datetime
from enum import Enum
import os
Expand Down Expand Up @@ -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)


Expand Down
2 changes: 1 addition & 1 deletion src/spring/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading