etcd-io/etcd · error
specify either 'addr' or 'download-ver'
Error message
specify either 'addr' or 'download-ver'
What it means
etcd-dump-metrics' main() accepts two mutually exclusive sources for metrics: -addr (an already-running etcd's metrics URL) and -download-ver (download an etcd binary of that version and scrape it locally). If both flags are non-empty at once, main panics with 'specify either addr or download-ver' because the two modes would conflict over which endpoint to fetch.
Source
Thrown at tools/etcd-dump-metrics/main.go:50
var lg *zap.Logger
func init() {
var err error
lg, err = logutil.CreateDefaultZapLogger(zap.InfoLevel)
if err != nil {
panic(err)
}
}
func main() {
addr := flag.String("addr", "", "etcd metrics URL to fetch from (empty to use current git branch)")
downloadVer := flag.String("download-ver", "", "etcd binary version to download and fetch metrics from")
debug := flag.Bool("debug", false, "true to enable debug logging")
flag.Parse()
if *addr != "" && *downloadVer != "" {
panic("specify either 'addr' or 'download-ver'")
}
if *debug {
var err error
lg, err = logutil.CreateDefaultZapLogger(zap.DebugLevel)
if err != nil {
panic(err)
}
}
ep := *addr
if ep == "" {
if *downloadVer != "" {
ver := *downloadVer
// download release binary to temporary directory
d, err := os.MkdirTemp(os.TempDir(), ver)
if err != nil {
panic(err)View on GitHub (pinned to f744d457f4)
Solutions
- Remove one of the two flags: keep `-addr` to scrape a live endpoint, or keep `-download-ver` to spin up a downloaded binary.
- If scripting, derive the invocation from a single mode variable so the two flags can never both be emitted.
- If neither flag is passed, confirm the fallback (build from current git branch) is what you want; otherwise pass exactly one.
Example fix
# before etcd-dump-metrics -addr http://localhost:2379/metrics -download-ver v3.5.0 # panic: specify either 'addr' or 'download-ver' # after (scrape a live endpoint) etcd-dump-metrics -addr http://localhost:2379/metrics # after (download and run a specific version) etcd-dump-metrics -download-ver v3.5.0
Defensive patterns
Strategy: validation
Validate before calling
# Validate in your wrapper before calling the tool: if [ -n "$ADDR" ] && [ -n "$DOWNLOAD_VER" ]; then echo "pass either -addr or -download-ver, not both" >&2; exit 2 fi
Prevention
- Pass exactly one of -addr / -download-ver per invocation.
- In scripts, model the mode as a single variable that expands to one flag.
- Audit copy-pasted CI commands when switching between live-scrape and download modes.
When it happens
Trigger: Running etcd-dump-metrics with both flags set on the command line, e.g. `etcd-dump-metrics -addr http://localhost:2379/metrics -download-ver v3.5.0`. Either flag alone (or neither, which defaults to building from the current git branch) is fine; only the both-set combination panics.
Common situations: Copy-pasted invocations in scripts where one mode was switched to another without removing the old flag; CI pipelines that template both flags unconditionally; assuming download-ver is ignored when addr is given.
Related errors
- %q doesn't seem like etcd binary
- Unknown result op
- bad compare value
- bad value %v of type %T
- unsupported stm
AI-assisted analysis of etcd-io/etcd@f744d457f4 (2026-08-15).
Data as JSON: /api/errors/31647a5a53f246f5.
Report an issue: GitHub.