github / github/github-ds

Incrementing a value into the negative does not work

Aberta
#65 0 comentários 0 reações 0 responsáveis Ver no GitHub
bug
Linguagem predominante
Ruby
Estrelas
700
Forks
29
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

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

Guia de contribuição

Abrir o guia de contribuição

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
ruby
Domínio
database
Tipo de issue
Bug
Dificuldade
3/5
Tempo estimado
1-2 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
35/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.