Merge "Ignore JSON decode error in request log."

This commit is contained in:
Zuul 2022-12-19 16:14:25 +00:00 committed by Gerrit Code Review
commit 7414d1c526
1 changed files with 5 additions and 3 deletions

View File

@ -211,10 +211,12 @@ class AuditLoggingHook(hooks.PecanHook):
def json_post_data(rest_state):
if 'form-data' in rest_state.request.headers.get('Content-Type'):
return " POST: {}".format(rest_state.request.params)
if not hasattr(rest_state.request, 'json'):
try:
if not hasattr(rest_state.request, 'json'):
return ""
return " POST: {}".format(rest_state.request.json)
except Exception:
return ""
return " POST: {}".format(rest_state.request.json)
# Filter password from log
filtered_json = re.sub(r'{[^{}]*(passwd_hash|community|password)[^{}]*},*',
'',