Skip to content

fix core: double truncation in request logging - #1344

Open
rjazhenka1 wants to merge 1 commit into
userver-framework:developfrom
rjazhenka1:fix-double-truncation
Open

fix core: double truncation in request logging#1344
rjazhenka1 wants to merge 1 commit into
userver-framework:developfrom
rjazhenka1:fix-double-truncation

Conversation

@rjazhenka1

@rjazhenka1 rjazhenka1 commented Sep 9, 2026

Copy link
Copy Markdown

Problem:

Request and response body logs are truncated twice, which results in (truncated, total X bytes) message having an incorrect size value (roughly around request_body_size_log_limit / response_data_size_log_limit).

1st truncation happens in GetRequestBodyForLogging() and GetResponseDataForLogging() (the resulting string is bigger than the limit due to the (truncated...) message).

2nd truncation happens in GetRequestBodyForLoggingChecked() and GetResponseDataForLoggingChecked(). Since the string from the 1st truncation is bigger than the limit, the string is truncated again and incorrect size is shown in the message.

Fix:

To fix the problem, I removed the 1st truncation call. This is okay, since request/response bodies are always truncated again in the 2nd call.

Before / after:

To showcase the issue, I used a simple request which consists of the letter "a" repeated for 10 KiB.

Before:
Screenshot_20260909_190244
After:
Screenshot_20260909_190823

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant