{"record":{"id":"fdb51aed43e13897","repo":"thanos-io/thanos","slug":"address-s-is-duplicated-for-query-flag","errorCode":null,"errorMessage":"Address %s is duplicated for --query flag.","messagePattern":"Address (.+?) is duplicated for --query flag\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/rule.go","lineNumber":216,"sourceCode":"\n\t\ttsdbOpts := &tsdb.Options{\n\t\t\tMinBlockDuration:  int64(time.Duration(*tsdbBlockDuration) / time.Millisecond),\n\t\t\tMaxBlockDuration:  int64(time.Duration(*tsdbBlockDuration) / time.Millisecond),\n\t\t\tRetentionDuration: int64(time.Duration(*tsdbRetention) / time.Millisecond),\n\t\t\tNoLockfile:        *noLockFile,\n\t\t\tWALCompression:    compressutil.ParseCompressionType(*walCompression, compression.Snappy),\n\t\t}\n\n\t\tagentOpts := &agent.Options{\n\t\t\tWALCompression: compressutil.ParseCompressionType(*walCompression, compression.Snappy),\n\t\t\tNoLockfile:     *noLockFile,\n\t\t}\n\n\t\t// Parse and check query configuration.\n\t\tlookupQueries := map[string]struct{}{}\n\t\tfor _, q := range conf.query.addrs {\n\t\t\tif _, ok := lookupQueries[q]; ok {\n\t\t\t\treturn errors.Errorf(\"Address %s is duplicated for --query flag.\", q)\n\t\t\t}\n\n\t\t\tlookupQueries[q] = struct{}{}\n\t\t}\n\n\t\tconf.queryConfigYAML, err = conf.query.configPath.Content()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif len(conf.query.sdFiles) == 0 && len(conf.query.addrs) == 0 && len(conf.queryConfigYAML) == 0 && len(conf.grpcQueryEndpoints) == 0 {\n\t\t\treturn errors.New(\"no query configuration parameter was given\")\n\t\t}\n\t\tif (len(conf.query.sdFiles) != 0 || len(conf.query.addrs) != 0 || len(conf.grpcQueryEndpoints) != 0) && len(conf.queryConfigYAML) != 0 {\n\t\t\treturn errors.New(\"--query/--query.sd-files/--grpc-query-endpoint and --query.config* parameters cannot be defined at the same time\")\n\t\t}\n\n\t\t// Parse and check alerting configuration.","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/rule.go#L198-L234","documentation":"The rule command requires each store API address given via --query to be unique. During Setup it builds a lookup map of conf.query.addrs and raises errors.Errorf when a duplicate address is seen. This is a configuration sanity check before constructing the store set.","triggerScenarios":"The same endpoint string appears twice in the --query flag list (or via repeated flags), e.g. --query=qa.example.com:9091 --query=qa.example.com:9091 (identical strings after normalization).","commonSituations":"Helm/Kustomize templates concatenating static and extra query addresses that overlap; copy-pasting the same address; service discovery config and static flags listing the same endpoint string.","solutions":["Deduplicate the --query address list so each endpoint appears exactly once.","Fix templating that appends extra addrs without dedup (use unique/sprig functions in Helm).","Use --query.sd-files or a query config file with deduped endpoints if the list is large.","Restart after correcting; note comparison is on the raw string, so ensure exact duplicates are removed."],"exampleFix":"// before\nthanos rule --query=qa:10901 --query=qb:10901 --query=qa:10901\n// after\nthanos rule --query=qa:10901 --query=qb:10901","handlingStrategy":"validation","validationCode":"def check_no_duplicate_queries(addrs):\n    dupes = {a for a in addrs if addrs.count(a) > 1}\n    if dupes:\n        raise SystemExit(f\"duplicate --query addresses: {sorted(dupes)}\")\n    return addrs","typeGuard":"def is_unique(seq):\n    return len(seq) == len(set(seq))","tryCatchPattern":null,"preventionTips":["Run uniq on the rendered query address list in deployment templates.","In Helm, use sprig 'uniq' when concatenating static and extra addresses.","Keep endpoint lists in one place (config file) to avoid drift across flags.","Add a preflight script that echoes and checks the final command line."],"tags":["cli","config","duplicate","validation"],"backgroundTag":"invalid-cli-argument","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}