{"record":{"id":"72204ad495161bad","repo":"thanos-io/thanos","slug":"query-query-sd-files-grpc-query-endpoint-and","errorCode":null,"errorMessage":"--query/--query.sd-files/--grpc-query-endpoint and --query.config* parameters cannot be defined at the same time","messagePattern":"--query/--query\\.sd-files/--grpc-query-endpoint and --query\\.config\\* parameters cannot be defined at the same time","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/rule.go","lineNumber":231,"sourceCode":"\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.\n\t\tconf.alertmgrsConfigYAML, err = conf.alertmgr.configPath.Content()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif len(conf.alertmgrsConfigYAML) != 0 && len(conf.alertmgr.alertmgrURLs) != 0 {\n\t\t\treturn errors.New(\"--alertmanagers.url and --alertmanagers.config* parameters cannot be defined at the same time\")\n\t\t}\n\n\t\tconf.alertRelabelConfigYAML, err = conf.alertmgr.alertRelabelConfigPath.Content()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\thttpLogOpts, err := logging.ParseHTTPOptions(reqLogConfig)\n\t\tif err != nil {","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/rule.go#L213-L249","documentation":"Thanos rule forbids mixing the static flag set (--query, --query.sd-files, --grpc-query-endpoint) with the file-based --query.config/--query.config-file. errors.New raises this when both styles are supplied at once, because endpoints must come from exactly one mechanism to avoid ambiguous configuration.","triggerScenarios":"Setup detects (len(sdFiles)!=0 || len(addrs)!=0 || len(grpcQueryEndpoints)!=0) && len(queryConfigYAML)!=0 and aborts, e.g. --query=qa:9090 together with --query.config-file=queries.yaml.","commonSituations":"Migrating from static flags to query config files but leaving old --query flags in the unit file; Helm chart default args plus user-supplied extraArgs containing --query.config; wrapper scripts appending both.","solutions":["Remove the --query/--query.sd-files/--grpc-query-endpoint flags and keep only --query.config-file (or vice versa).","Move all endpoints from the static flags into the query config YAML endpoints list.","Audit startup scripts/Helm extraArgs for leftovers from a migration.","Restart and confirm only one style of query configuration is present (print the full command line)."],"exampleFix":"// before\nthanos rule --query=qa:9090 --query.config-file=queries.yaml\n// after\nthanos rule --query.config-file=queries.yaml   # all endpoints inside queries.yaml","handlingStrategy":"validation","validationCode":"def check_query_flags_mutually_exclusive(args):\n    static = {\"--query\", \"--query.sd-files\", \"--grpc-query-endpoint\"}\n    filebased = {\"--query.config\", \"--query.config-file\"}\n    given = {a.split(\"=\")[0] for a in args if a.startswith(\"--\")}\n    if given & static and given & filebased:\n        raise SystemExit(\"use either --query/--query.sd-files/--grpc-query-endpoint OR --query.config*, not both\")","typeGuard":"def query_flags_valid(args):\n    static = any(a.split(\"=\")[0] in {\"--query\", \"--query.sd-files\", \"--grpc-query-endpoint\"} for a in args)\n    filebased = any(a.split(\"=\")[0] in {\"--query.config\", \"--query.config-file\"} for a in args)\n    return not (static and filebased)","tryCatchPattern":null,"preventionTips":["Pick one mechanism (prefer --query.config-file) and enforce it in your chart/unit.","Grep startup scripts for leftover --query flags when migrating to config files.","Block conflicting args with a wrapper script assertion.","Review 'extraArgs' sections in Helm values after upgrades."],"tags":["cli","config","conflicting-options","startup"],"backgroundTag":"mutually-exclusive-flags","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"}