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
7 changes: 7 additions & 0 deletions .chronus/changes/failsafe_deserialize-2025-7-6-14-50-25.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: dependencies
packages:
- "@autorest/python"
---

Bump dependency on `http-client-python`
7 changes: 7 additions & 0 deletions .chronus/changes/failsafe_deserialize-2025-7-6-14-50-45.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- "@azure-tools/typespec-python"
---

Don't throw when deserializing error model responses
2 changes: 1 addition & 1 deletion packages/autorest.python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"homepage": "https://github.com/Azure/autorest.python/blob/main/README.md",
"dependencies": {
"@typespec/http-client-python": "~0.15.0",
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNTE4NzMzOC9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.15.0.tgz",
"@autorest/system-requirements": "~1.0.2",
"fs-extra": "~11.2.0",
"tsx": "~4.19.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/typespec-python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"js-yaml": "~4.1.0",
"semver": "~7.6.2",
"tsx": "~4.19.1",
"@typespec/http-client-python": "~0.15.0",
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNTE4NzMzOC9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.15.0.tgz",
"fs-extra": "~11.2.0"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def invalid(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = None
if response.status_code == 403:
error = _failsafe_deserialize(_models.InvalidAuth, response.json())
error = _failsafe_deserialize(_models.InvalidAuth, response)
raise HttpResponseError(response=response, model=error)

if cls:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from azure.core import CaseInsensitiveEnumMeta
from azure.core.pipeline import PipelineResponse
from azure.core.serialization import _Null
from azure.core.rest import HttpResponse

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -940,13 +941,13 @@ def _deserialize(

def _failsafe_deserialize(
deserializer: typing.Any,
value: typing.Any,
response: HttpResponse,
module: typing.Optional[str] = None,
rf: typing.Optional["_RestField"] = None,
format: typing.Optional[str] = None,
) -> typing.Any:
try:
return _deserialize(deserializer, value, module, rf, format)
return _deserialize(deserializer, response.json(), module, rf, format)
except DeserializationError:
_LOGGER.warning(
"Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True
Expand All @@ -956,10 +957,10 @@ def _failsafe_deserialize(

def _failsafe_deserialize_xml(
deserializer: typing.Any,
value: typing.Any,
response: HttpResponse,
) -> typing.Any:
try:
return _deserialize_xml(deserializer, value)
return _deserialize_xml(deserializer, response.text())
except DeserializationError:
_LOGGER.warning(
"Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ async def invalid(self, **kwargs: Any) -> None:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = None
if response.status_code == 403:
error = _failsafe_deserialize(_models.InvalidAuth, response.json())
error = _failsafe_deserialize(_models.InvalidAuth, response)
raise HttpResponseError(response=response, model=error)

if cls:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def invalid(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = None
if response.status_code == 403:
error = _failsafe_deserialize(_models.InvalidAuth, response.json())
error = _failsafe_deserialize(_models.InvalidAuth, response)
raise HttpResponseError(response=response, model=error)

if cls:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from azure.core import CaseInsensitiveEnumMeta
from azure.core.pipeline import PipelineResponse
from azure.core.serialization import _Null
from azure.core.rest import HttpResponse

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -940,13 +941,13 @@ def _deserialize(

def _failsafe_deserialize(
deserializer: typing.Any,
value: typing.Any,
response: HttpResponse,
module: typing.Optional[str] = None,
rf: typing.Optional["_RestField"] = None,
format: typing.Optional[str] = None,
) -> typing.Any:
try:
return _deserialize(deserializer, value, module, rf, format)
return _deserialize(deserializer, response.json(), module, rf, format)
except DeserializationError:
_LOGGER.warning(
"Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True
Expand All @@ -956,10 +957,10 @@ def _failsafe_deserialize(

def _failsafe_deserialize_xml(
deserializer: typing.Any,
value: typing.Any,
response: HttpResponse,
) -> typing.Any:
try:
return _deserialize_xml(deserializer, value)
return _deserialize_xml(deserializer, response.text())
except DeserializationError:
_LOGGER.warning(
"Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ async def invalid(self, **kwargs: Any) -> None:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = None
if response.status_code == 403:
error = _failsafe_deserialize(_models.InvalidAuth, response.json())
error = _failsafe_deserialize(_models.InvalidAuth, response)
raise HttpResponseError(response=response, model=error)

if cls:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def invalid(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = None
if response.status_code == 403:
error = _failsafe_deserialize(_models.InvalidAuth, response.json())
error = _failsafe_deserialize(_models.InvalidAuth, response)
raise HttpResponseError(response=response, model=error)

if cls:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from azure.core import CaseInsensitiveEnumMeta
from azure.core.pipeline import PipelineResponse
from azure.core.serialization import _Null
from azure.core.rest import HttpResponse

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -940,13 +941,13 @@ def _deserialize(

def _failsafe_deserialize(
deserializer: typing.Any,
value: typing.Any,
response: HttpResponse,
module: typing.Optional[str] = None,
rf: typing.Optional["_RestField"] = None,
format: typing.Optional[str] = None,
) -> typing.Any:
try:
return _deserialize(deserializer, value, module, rf, format)
return _deserialize(deserializer, response.json(), module, rf, format)
except DeserializationError:
_LOGGER.warning(
"Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True
Expand All @@ -956,10 +957,10 @@ def _failsafe_deserialize(

def _failsafe_deserialize_xml(
deserializer: typing.Any,
value: typing.Any,
response: HttpResponse,
) -> typing.Any:
try:
return _deserialize_xml(deserializer, value)
return _deserialize_xml(deserializer, response.text())
except DeserializationError:
_LOGGER.warning(
"Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ async def invalid(self, **kwargs: Any) -> None:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = None
if response.status_code == 403:
error = _failsafe_deserialize(_models.InvalidAuth, response.json())
error = _failsafe_deserialize(_models.InvalidAuth, response)
raise HttpResponseError(response=response, model=error)

if cls:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def invalid(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = None
if response.status_code == 403:
error = _failsafe_deserialize(_models.InvalidAuth, response.json())
error = _failsafe_deserialize(_models.InvalidAuth, response)
raise HttpResponseError(response=response, model=error)

if cls:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from azure.core import CaseInsensitiveEnumMeta
from azure.core.pipeline import PipelineResponse
from azure.core.serialization import _Null
from azure.core.rest import HttpResponse

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -940,13 +941,13 @@ def _deserialize(

def _failsafe_deserialize(
deserializer: typing.Any,
value: typing.Any,
response: HttpResponse,
module: typing.Optional[str] = None,
rf: typing.Optional["_RestField"] = None,
format: typing.Optional[str] = None,
) -> typing.Any:
try:
return _deserialize(deserializer, value, module, rf, format)
return _deserialize(deserializer, response.json(), module, rf, format)
except DeserializationError:
_LOGGER.warning(
"Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True
Expand All @@ -956,10 +957,10 @@ def _failsafe_deserialize(

def _failsafe_deserialize_xml(
deserializer: typing.Any,
value: typing.Any,
response: HttpResponse,
) -> typing.Any:
try:
return _deserialize_xml(deserializer, value)
return _deserialize_xml(deserializer, response.text())
except DeserializationError:
_LOGGER.warning(
"Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ async def invalid(self, **kwargs: Any) -> None:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = None
if response.status_code == 403:
error = _failsafe_deserialize(_models.InvalidAuth, response.json())
error = _failsafe_deserialize(_models.InvalidAuth, response)
raise HttpResponseError(response=response, model=error)

if cls:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from azure.core import CaseInsensitiveEnumMeta
from azure.core.pipeline import PipelineResponse
from azure.core.serialization import _Null
from azure.core.rest import HttpResponse

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -940,13 +941,13 @@ def _deserialize(

def _failsafe_deserialize(
deserializer: typing.Any,
value: typing.Any,
response: HttpResponse,
module: typing.Optional[str] = None,
rf: typing.Optional["_RestField"] = None,
format: typing.Optional[str] = None,
) -> typing.Any:
try:
return _deserialize(deserializer, value, module, rf, format)
return _deserialize(deserializer, response.json(), module, rf, format)
except DeserializationError:
_LOGGER.warning(
"Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True
Expand All @@ -956,10 +957,10 @@ def _failsafe_deserialize(

def _failsafe_deserialize_xml(
deserializer: typing.Any,
value: typing.Any,
response: HttpResponse,
) -> typing.Any:
try:
return _deserialize_xml(deserializer, value)
return _deserialize_xml(deserializer, response.text())
except DeserializationError:
_LOGGER.warning(
"Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from azure.core import CaseInsensitiveEnumMeta
from azure.core.pipeline import PipelineResponse
from azure.core.serialization import _Null
from azure.core.rest import HttpResponse

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -940,13 +941,13 @@ def _deserialize(

def _failsafe_deserialize(
deserializer: typing.Any,
value: typing.Any,
response: HttpResponse,
module: typing.Optional[str] = None,
rf: typing.Optional["_RestField"] = None,
format: typing.Optional[str] = None,
) -> typing.Any:
try:
return _deserialize(deserializer, value, module, rf, format)
return _deserialize(deserializer, response.json(), module, rf, format)
except DeserializationError:
_LOGGER.warning(
"Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True
Expand All @@ -956,10 +957,10 @@ def _failsafe_deserialize(

def _failsafe_deserialize_xml(
deserializer: typing.Any,
value: typing.Any,
response: HttpResponse,
) -> typing.Any:
try:
return _deserialize_xml(deserializer, value)
return _deserialize_xml(deserializer, response.text())
except DeserializationError:
_LOGGER.warning(
"Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from azure.core import CaseInsensitiveEnumMeta
from azure.core.pipeline import PipelineResponse
from azure.core.serialization import _Null
from azure.core.rest import HttpResponse

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -940,13 +941,13 @@ def _deserialize(

def _failsafe_deserialize(
deserializer: typing.Any,
value: typing.Any,
response: HttpResponse,
module: typing.Optional[str] = None,
rf: typing.Optional["_RestField"] = None,
format: typing.Optional[str] = None,
) -> typing.Any:
try:
return _deserialize(deserializer, value, module, rf, format)
return _deserialize(deserializer, response.json(), module, rf, format)
except DeserializationError:
_LOGGER.warning(
"Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True
Expand All @@ -956,10 +957,10 @@ def _failsafe_deserialize(

def _failsafe_deserialize_xml(
deserializer: typing.Any,
value: typing.Any,
response: HttpResponse,
) -> typing.Any:
try:
return _deserialize_xml(deserializer, value)
return _deserialize_xml(deserializer, response.text())
except DeserializationError:
_LOGGER.warning(
"Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True
Expand Down
Loading
Loading