Skip to content

Commit

Permalink
Strip useless linebreak in the payload of send:exception events (#7407)
Browse files Browse the repository at this point in the history
`traceback.format_exception` adds a `\n` to each element of the
resulting list, so the message will always have a pointless `\n` at the
end. Removing it makes CSV reports that include the message easier to
parse visually, because there's no longer a linebreak in the middle of
each line.
  • Loading branch information
SpecLad committed Jan 31, 2024
1 parent 7a9c1f4 commit c794836
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions changelog.d/20240129_190242_roman_HEAD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### Changed

- The "message" field of the payload of send:exception events
no longer includes a trailing linebreak
(<https://github.com/opencv/cvat/pull/7407>)
4 changes: 2 additions & 2 deletions cvat/apps/events/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ def handle_rq_exception(rq_job, exc_type, exc_value, tb):
tb_strings = traceback.format_exception(exc_type, exc_value, tb)

payload = {
"message": tb_strings[-1],
"message": tb_strings[-1].rstrip("\n"),
"stack": ''.join(tb_strings),
}

Expand Down Expand Up @@ -563,7 +563,7 @@ def handle_viewset_exception(exc, context):
"content_type": request.content_type,
"method": request.method,
},
"message": tb_strings[-1],
"message": tb_strings[-1].rstrip("\n"),
"stack": ''.join(tb_strings),
"status_code": status_code,
}
Expand Down

0 comments on commit c794836

Please sign in to comment.