Improve exception handling in Flodesk::Client
まだ誰も着手していません。
評価
調査の方向性
lib/flodesk.rb の Client#request から開始し、70–74 行付近にある戻り値の型チェックを調べます。response_body が存在しない場合の接続エラーの経路を確認し、呼び出し元の動作を更新して、既存の Flodesk 関連の specs を実行し、エラーが発生することと nil のケースで NoMethodError が発生しなくなったことを確認します。
索引モデルが issue の本文から書いたものです。
説明
Currently we've got the following code in Client#request:
Make code nil-safe
This can result in a NoMethodError: undefined method '[]' for nil if there is an issue connecting to Flodesk and the response doesn't actually contain a message_body.
This could happen in production, but also can be a source of flaky tests as happened recently.
Proposing to make this nil-safe by using e.response_body&.['message']
Raise rather than return the exception
Currently this code is actually returning the FlodeskError rather than raising it.
Proposing to raise the exception instead, but note there's one place where we currently check the return type from the method that will need updating to reflect this change:
Mock out the client in tests
As a separate task we can take a look at mocking → Fixed on https://github.com/codebar/planner/pull/2402Flodesk::Client in the specs.
- 主要言語
- Ruby
- スター
- 104
- フォーク
- 205
- 平均マージ
- 1日 8時間
- マージ済み PR(30日)
- 67
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
codebar/planner のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
-
good first issue performance
難易度 3/5 1〜2日 初心者へのやさしさ 78/100
codebar/planner の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
riscv/riscv-unified-db#2626 ·
-
Component: GLib
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
ds-drift
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
we-promise/sure#3693 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
simp/pupmod-simp-simp#395 ·