github / github/github-ds

Incrementing a value into the negative does not work

Ouverte
#65 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
bug
Langage dominant
Ruby
Étoiles
700
Forks
29
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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'
```

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
ruby
Domaine
database
Type d'issue
Bug
Difficulté
3/5
Temps estimé
1-2 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.