Failed HEAD request drops Retry-After and the error code and message

オープン 初心者向け
#247 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
74/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java
領域
api, networking

調査の方向性

httpclient/src/main/java/com/backblaze/b2/client/webApiHttpClient/B2WebApiHttpClientImpl.java から始めます。head() の 178 行目付近にある 200 以外の応答を処理する else 分岐を読み、286 行目の POST の処理経路、extractExceptionFromErrorResponse、getRetryAfterSecondsOrNull(303~314 行目付近)と比較してください。HEAD の失敗でも、POST と同じようにエラーコード、メッセージ、Retry-After を保持するようにします。モックした 503 応答で Retry-After: 7 を HEAD に返したとき、getRetryAfterSecondsOrNull() が 7 を返し、エラーコードとメッセージが設定されていれば完了です。

索引モデルが issue の本文から書いたものです。

説明

What happens

When B2WebApiHttpClientImpl.head() gets a status other than 200, it throws B2Exception.create(null, statusCode, null, ""). The error has no code and an empty message, and the Retry-After header is ignored, so a 429 or 503 on a HEAD request is retried with the default delay rather than the server's. The POST path keeps all of these.

Where

httpclient/src/main/java/com/backblaze/b2/client/webApiHttpClient/B2WebApiHttpClientImpl.java:178 (head); compare :286 and :303-314 (getRetryAfterSecondsOrNull) used by the POST path.

Why it matters

Impact: Wrong request or result (a poorer error and wrong retry delay), loud. Severity: High, because it happens on every failed HEAD request (normal path for errors), and there is no workaround besides reading the status code from the exception.

How to check

Found by reading the code, not reproduced. Read the else branch in head() and compare it with extractExceptionFromErrorResponse. A test with a mock HTTP client returning 503 with Retry-After: 7 on a HEAD should show getRetryAfterSecondsOrNull() as null.

Version

Seen at v6.5.0. Present on the default branch: present.

主要言語
Java
スター
103
フォーク
23
平均マージ
5日 8時間
マージ済み PR(30日)
3

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Backblaze/b2-sdk-java のほかの issue

Backblaze/b2-sdk-java の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。