Skip to content

Commit 0af5a99

Browse files
committed
Skip email replacer if the request body is not string, for example it could be a zip file
1 parent 5c3cf2f commit 0af5a99

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/azure-cli-testsdk/azure/cli/testsdk/utilities.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,12 @@ def _replace_email_address(self, text):
223223
def process_request(self, request):
224224
request.uri = self._replace_email_address(request.uri)
225225
if request.body:
226-
body = _byte_to_str(request.body)
227-
request.body = self._replace_email_address(body)
226+
try:
227+
body = _byte_to_str(request.body)
228+
request.body = self._replace_email_address(body)
229+
except UnicodeDecodeError:
230+
# If the body is not a string, we cannot decode it, so we skip the replacement
231+
pass
228232
return request
229233

230234
def process_response(self, response):

0 commit comments

Comments
 (0)