{"record":{"id":"c1eaef1c31267c57","repo":"etcd-io/etcd","slug":"q-doesn-t-seem-like-etcd-binary","errorCode":null,"errorMessage":"%q doesn't seem like etcd binary","messagePattern":"%q doesn't seem like etcd binary","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tools/etcd-dump-metrics/etcd.go","lineNumber":65,"sourceCode":"\tif err != nil {\n\t\tpanic(err)\n\t}\n\tos.RemoveAll(cfg.Dir)\n\n\tcfg.ClusterState = \"new\"\n\tcfg.ListenClientUrls, cfg.AdvertiseClientUrls = curls, curls\n\tcfg.ListenPeerUrls, cfg.AdvertisePeerUrls = purls, purls\n\n\tcfg.InitialCluster = \"\"\n\tfor i := range ics {\n\t\tcfg.InitialCluster += fmt.Sprintf(\",%d=%s\", i, ics[i].String())\n\t}\n\tcfg.InitialCluster = cfg.InitialCluster[1:]\n}\n\nfunc getCommand(exec, name, dir, cURL, pURL, cluster string) (args []string) {\n\tif !strings.Contains(exec, \"etcd\") {\n\t\tpanic(fmt.Errorf(\"%q doesn't seem like etcd binary\", exec))\n\t}\n\treturn []string{\n\t\texec,\n\t\t\"--name\", name,\n\t\t\"--data-dir\", dir,\n\t\t\"--listen-client-urls\", cURL,\n\t\t\"--advertise-client-urls\", cURL,\n\t\t\"--listen-peer-urls\", pURL,\n\t\t\"--initial-advertise-peer-urls\", pURL,\n\t\t\"--initial-cluster\", cluster,\n\t\t\"--initial-cluster-token=tkn\",\n\t\t\"--initial-cluster-state=new\",\n\t}\n}\n\nfunc write(ep string) {\n\tcli, err := clientv3.New(clientv3.Config{Endpoints: []string{strings.Replace(ep, \"/metrics\", \"\", 1)}})\n\tif err != nil {","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/etcd-io/etcd/blob/f744d457f484e9f748a0700b48ef96dcf792df33/tools/etcd-dump-metrics/etcd.go#L47-L83","documentation":"etcd-dump-metrics spawns a real etcd process to scrape its /metrics, and getCommand guards that the -exec path actually looks like an etcd binary by requiring the substring \"etcd\" in the executable path. It panics otherwise — a deliberately crude sanity check so the tool does not launch an arbitrary unrelated executable with etcd flags.","triggerScenarios":"Invoking etcd-dump-metrics with `-exec <path>` where path does not contain the literal substring \"etcd\" (e.g. `--exec ./bin/server` or `--exec /opt/my-binary`). The check is a plain strings.Contains, so even a valid etcd binary renamed without 'etcd' in its path fails it.","commonSituations":"CI or a wrapper script renames/copies the etcd binary to a neutral name; users pass a wrapper shell script as -exec; typos in the path; using a custom build artifact named differently.","solutions":["Point -exec at a path that contains 'etcd', e.g. `--exec ./bin/etcd` or `--exec /usr/local/bin/etcd`.","If the binary must keep its name, create a symlink whose name contains etcd: `ln -s /opt/my-server ./etcd-server && --exec ./etcd-server`.","Omit -exec entirely so the tool downloads/uses a stock etcd binary (pair it with -download-ver), which always satisfies the check."],"exampleFix":"# before\netcd-dump-metrics --exec ./bin/server ...   # panics: %q doesn't seem like etcd binary\n\n# after\netcd-dump-metrics --exec ./bin/etcd ...\n# or\nln -s ./bin/server ./bin/etcd-server && etcd-dump-metrics --exec ./bin/etcd-server ...","handlingStrategy":"validation","validationCode":"# Validate before invoking the tool:\n[ \"$(basename \"$EXEC_PATH\")\" != \"${EXEC_PATH/*etcd*/}\" ] || { echo \"exec path must contain 'etcd'\" >&2; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep etcd binaries on paths that contain 'etcd' in the filename.","Wrap custom binaries with a symlink named *etcd* for tooling.","Prefer -download-ver over -exec when you just need metrics for a version."],"tags":["etcd-dump-metrics","cli","tooling","panic"],"backgroundTag":null,"analyzedSha":"f744d457f484e9f748a0700b48ef96dcf792df33","analyzedAt":"2026-08-15T09:39:50.079Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}