lease comparison in txn bug
- Dominant language
- Go
- Stars
- 52.3k
- Forks
- 10.5k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 43
Description
### Bug report criteria
- [x] This bug report is not security related, security issues should be disclosed privately via security@etcd.io.
- [x] This is not a support request or question, support requests or questions should be raised in the etcd [discussion forums](https://github.com/etcd-io/etcd/discussions).
- [x] You have read the etcd [bug reporting guidelines](https://github.com/etcd-io/etcd/blob/main/Documentation/contributor-guide/reporting_bugs.md).
- [x] Existing open issues along with etcd [frequently asked questions](https://etcd.io/docs/latest/faq) have been checked and this is not a duplicate.
### What happened?
When I try to execute a lease comparison in a transaction (txn), etcdctl returns the error **"panic: bad value"** in goroutine.
### What did you expect to happen?
Initially, the database is empty. I put the key value _{foo2: bar2}_ in the database, so I expected (replace \ with your hostname):
```console
$ etcdctl --endpoints=:2379 txn <<<'lease("foo1") > "0"
get foo1
get foo2
'
FAILURE
foo2
bar2
```
### How can we reproduce it (as minimally and precisely as possible)?
I started database with command (replace \ with your hostname):
```console
$ etcd --listen-client-urls http://:2379 --advertise-client-urls http://:2379 --log-level 'debug'
```
In fact, you don't even need to run the database, because there is an error on the client.
Then I run:
```console
$ etcdctl --endpoints=:2379 txn <<<'lease("foo1") > "0"
get foo1
get foo2
'
```
### Anything else we need to know?
I found a similar issue https://github.com/etcd-io/etcd/issues/14845 from three years ago, but it was closed, because an unsupported version was used in the bug report.
### Etcd version (please run commands below)
```console
$ etcd --version
etcd Version: 3.7.0-alpha.0
Git SHA: 438ed9693
Go Version: go1.25.1
Go OS/Arch: linux/amd64
$ etcdctl version
etcdctl version: 3.7.0-alpha.0
API version: 3.7
```
### Etcd configuration (command line flags or environment variables)
_No response_
### Etcd debug information (please run commands below, feel free to obfuscate the IP address or FQDN in the output)
_No response_
### Relevant log output
```Shell
$ etcdctl --endpoints=:2379 txn <<<'lease("foo1") > "0"
get foo1
get foo2
'
panic: bad value
goroutine 1 [running]:
go.etcd.io/etcd/client/v3.mustInt64(...)
go.etcd.io/etcd/client/v3/compare.go:132
go.etcd.io/etcd/client/v3.mustInt64orLeaseID(...)
go.etcd.io/etcd/client/v3/compare.go:141
go.etcd.io/etcd/client/v3.Compare({0x1, 0x4, {0x0, 0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0, 0x0}, ...}, ...)
go.etcd.io/etcd/client/v3/compare.go:66 +0x36c
go.etcd.io/etcd/etcdctl/v3/ctlv3/command.ParseCompare({0xc000154828, 0x13})
go.etcd.io/etcd/etcdctl/v3/ctlv3/command/txn_command.go:225 +0x507
go.etcd.io/etcd/etcdctl/v3/ctlv3/command.readCompares(0xc000111c18)
go.etcd.io/etcd/etcdctl/v3/ctlv3/command/txn_command.go:112 +0xc5
go.etcd.io/etcd/etcdctl/v3/ctlv3/command.txnCommandFunc(0xc0001ed808, {0xc0002f2dd0?, 0x4?, 0xd964e7?})
go.etcd.io/etcd/etcdctl/v3/ctlv3/command/txn_command.go:79 +0x1e8
github.com/spf13/cobra.(*Command).execute(0xc0001ed808, {0xc0002f2db0, 0x1, 0x1})
github.com/spf13/cobra@v1.10.1/command.go:1019 +0xae7
github.com/spf13/cobra.(*Command).ExecuteC(0x153bbc0)
github.com/spf13/cobra@v1.10.1/command.go:1148 +0x465
github.com/spf13/cobra.(*Command).Execute(...)
github.com/spf13/cobra@v1.10.1/command.go:1071
go.etcd.io/etcd/etcdctl/v3/ctlv3.Start(...)
go.etcd.io/etcd/etcdctl/v3/ctlv3/ctl.go:121
go.etcd.io/etcd/etcdctl/v3/ctlv3.MustStart()
go.etcd.io/etcd/etcdctl/v3/ctlv3/ctl.go:125 +0x1a
main.main()
go.etcd.io/etcd/etcdctl/v3/main.go:23 +0xf
```
Contributor guide
Research direction
Start with client/v3/compare.go, especially mustInt64 and mustInt64orLeaseID, then follow the ParseCompare entry point in etcdctl/v3/ctlv3/command/txn_command.go. Reproduce the supplied etcdctl transaction command and trace why the lease comparison causes a panic. Done means the command handles this comparison without panicking and produces the expected transaction result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100