Skip to content

Commit

Permalink
Improve debugging unexpected values in request block (#772)
Browse files Browse the repository at this point in the history
Log the values (excluding tokens) to help pinpoint unexpected types of values in the request block.

Testing:
- manual testing with invalid dictionary ('restler_fuzzable_int' containing integer instead of string)
  • Loading branch information
marina-p committed Jun 8, 2023
1 parent ccb7731 commit 28e0ec5
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions restler/engine/core/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,8 @@ def render_iter(self, candidate_values_pool, skip=0, preprocessing=False, prev_r
@rtype : (Str, Function Pointer, List[Str])
"""
from engine.core.request_utilities import replace_auth_token

def _handle_exception(type, tag, err):
logger.write_to_main(
f"Exception when rendering request {self.method} {self.endpoint_no_dynamic_objects}.\n"
Expand Down Expand Up @@ -1227,8 +1229,22 @@ def _handle_exception(type, tag, err):
if value_list:
rendered_data = values
else:
rendered_data = "".join(values)

try:
rendered_data = "".join(values)
except Exception as err:
debug_values = []
for v in values:
if isinstance(v, str):
debug_values.append(replace_auth_token(v, '_OMITTED_AUTH_TOKEN_'))
else:
debug_values.append(v)
logger.write_to_main(
f"Exception when rendering request {self.method} {self.endpoint_no_dynamic_objects}.\n"
f"Request block values: {debug_values}\n"
f" Exception: {err!s}",
print_to_console=True
)
raise
# Save the schema for this combination.
self._last_rendered_schema_request = (req, is_example)

Expand Down

0 comments on commit 28e0ec5

Please sign in to comment.