github / github/github-ds

Incrementing a value into the negative does not work

オープン
#65 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
bug
主要言語
Ruby
スター
700
フォーク
29
PR マージ指標
30日以内にマージされた PR はありません

説明

When using the [`increment`](https://github.com/github/github-ds/blob/f964ab2d75272d5b5d2fef68416abcab7bd2dc3a/lib/github/kv.rb#L287) method, if you increment the value below 0, the output is unexpected and subsequent `increment`s fail.

```ruby
> GitHub.kv.get(kv_key).value! { 0 }
nil

> GitHub.kv.increment(kv_key)
1

> GitHub.kv.get(kv_key).value! { 0 }
"1"

> GitHub.kv.increment(kv_key, amount: -2)
18446744073709551615

> GitHub.kv.get(kv_key).value! { 0 }
"18446744073709551615"

> GitHub.kv.increment(kv_key, amount: 2)
eval error: GitHub::KV::InvalidValueError
vendor/gems/3.2.2/ruby/3.2.0/gems/github-ds-0.5.2.10.g8cf56ba:in `block in increment'
```

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

Start in lib/github/kv.rb at the increment method around line 287 and reproduce the documented sequence, including the negative amount. Done means incrementing below zero produces the intended value and a later positive increment no longer raises InvalidValueError; add or update focused coverage if the repository provides a relevant test location.

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

評価

技術スタック
ruby
領域
database
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

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

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