fix(errors): never print a blank error for an empty response body - #232
Merged
Conversation
Under heavy load a small fraction of requests (~0.02-0.06%) failed with
an error line that was nothing but ANSI color codes: a dropped
connection or bodyless 5xx produced an empty body, api_error() echoed
it verbatim, and print paths rendered red("") — invisible output with
exit 1.
- util::api_error: empty/whitespace body now falls back to 'unexpected
empty response from server' (covers every caller, including the
direct api_error(...).red() prints in databases.rs).
- sdk::format_fail_message: when the body is empty the HTTP status is
the only signal there is, so surface it: 'error: HTTP 502 Bad Gateway
(empty response body)'.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
During the #230 load tests, a small fraction of requests (~0.02–0.06% at 32–1024-way concurrency) failed with stderr containing only ANSI color codes — an invisible error message with exit 1. Root cause: a dropped connection or bodyless 5xx yields an empty response body;
util::api_errorechoes the body verbatim when it isn't JSON/HTML, and the print paths renderred("").Fix
util::api_error: an empty/whitespace body falls back tounexpected empty response from server— covers every caller, including the directapi_error(...).red()prints indatabases.rs.sdk::format_fail_message: with an empty body the HTTP status is the only signal available, so it's surfaced:error: HTTP 502 Bad Gateway (empty response body). This is the pathApiError::print()/exit()uses, i.e. whatdatabases createfailures under load hit.ApiError::Transportmessages were audited too — every construction site prefixes them, so they can't be blank.Tests
api_error_never_returns_blank_for_empty_bodyformat_fail_message_empty_body_surfaces_statusFollow-up from #230 (second follow-up there — un-timeouted
Client::new()inauth.rs/credentials.rs— still open).