Skip to content

Commit

Permalink
fix: improve 503 handling for json resumable session query
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-mwnukowski committed Mar 7, 2025
1 parent 8bcb2de commit 75138ba
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,17 @@ final class JsonResumableSessionQueryTask
} else {
HttpResponseException cause = new HttpResponseException(response);
String contentType = response.getHeaders().getContentType();
Long contentLength = response.getHeaders().getContentLength();
// If the content-range header value has run ahead of the backend, it will respond with
// a 503 with plain text content
// Attempt to detect this very loosely as to minimize impact of modified error message
// This is accurate circa 2023-06
if ((!ResumableSessionFailureScenario.isOk(code)
&& !ResumableSessionFailureScenario.isContinue(code))
&& contentType != null
&& contentType.startsWith("text/plain")) {
&& contentType.startsWith("text/plain")
&& contentLength != null
&& contentLength > 0) {
String errorMessage = cause.getContent().toLowerCase(Locale.US);
if (errorMessage.contains("content-range")) {
throw ResumableSessionFailureScenario.SCENARIO_5.toStorageException(
Expand Down

0 comments on commit 75138ba

Please sign in to comment.