Skip to content

Commit

Permalink
Fix retry bug for jsonc template policy (Azure#21220)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhoxing-ms authored Feb 24, 2022
1 parent 3b386ee commit 899f18c
Show file tree
Hide file tree
Showing 3 changed files with 224 additions and 216 deletions.
10 changes: 9 additions & 1 deletion src/azure-cli/azure/cli/command_modules/resource/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,15 @@ class JsonCTemplatePolicy(SansIOHTTPPolicy):

def on_request(self, request):
http_request = request.http_request
if (getattr(http_request, 'data', {}) or {}).get('properties', {}).get('template'):
request_data = getattr(http_request, 'data', {}) or {}

# In the case of retry, because the first request has been processed and
# converted the type of "request.http_request.data" from string to bytes,
# so there is no need to process request object again during retry
if isinstance(request_data, bytes):
return

if request_data.get('properties', {}).get('template'):
template = http_request.data["properties"]["template"]
if not isinstance(template, JsonCTemplate):
raise ValueError()
Expand Down
Loading

0 comments on commit 899f18c

Please sign in to comment.