hypothesis / hypothesis/lms

Truncate long request and response bodies before monitoring or logging

Open
#3,321 0 comments 0 reactions 1 assignee Claimed by @seanh View on GitHub
Backend
Dominant language
Python
Stars
53
Forks
16
Avg merge
14d 5h
Merged PRs (30d)
14

Description

When an external request fails `HTTPService` [raises `ExternalRequestError` passing the failed `request` and `response`](https://github.com/hypothesis/lms/blob/db1874d1e4b9d9be373b6fabecfd2be0023140e9/lms/services/http.py#L90). The request and response are then logged to Papertrail via [`HTTPService.__str__()`](https://github.com/hypothesis/lms/blob/db1874d1e4b9d9be373b6fabecfd2be0023140e9/lms/services/exceptions.py#L58-L83) and also sent to Sentry and to the frontend by the [`external_request_error()` exception view](https://github.com/hypothesis/lms/blob/db1874d1e4b9d9be373b6fabecfd2be0023140e9/lms/views/api/exceptions.py#L105-L147).

When sending a request or response body to Papertrail, Sentry or the frontend we should truncate it to make sure we don't send too much data.

Note that we actually _want_ to send the entire body for debugging purposes. But just not if the body is so massive that trying to send the whole thing is going to cause problems. So we'll want to set the truncation limit quite high

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.