{"record":{"id":"dabaaa792646aebb","repo":"thanos-io/thanos","slug":"unable-to-create-new-legacy-file-sd-config-w","errorCode":null,"errorMessage":"unable to create new legacy file sd config: %w","messagePattern":"unable to create new legacy file sd config: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/endpointset.go","lineNumber":366,"sourceCode":"\t\t\t\tduplicatedEndpoints.Inc()\n\t\t\t}\n\t\t\tset[addr] = spec\n\t\t}\n\t\tdeduplicated := make([]*query.GRPCEndpointSpec, 0, len(set))\n\t\tfor _, value := range set {\n\t\t\tdeduplicated = append(deduplicated, value)\n\t\t}\n\t\treturn deduplicated\n\t}\n\tvar fileSD *file.Discovery\n\tif len(legacyFileSDFiles) > 0 {\n\t\tconf := &file.SDConfig{\n\t\t\tFiles:           legacyFileSDFiles,\n\t\t\tRefreshInterval: model.Duration(legacyFileSDInterval),\n\t\t}\n\t\tvar err error\n\t\tif fileSD, err = file.NewDiscovery(conf, logutil.GoKitLogToSlog(logger), conf.NewDiscovererMetrics(reg, discovery.NewRefreshMetrics(reg))); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"unable to create new legacy file sd config: %w\", err)\n\t\t}\n\t}\n\tlegacyFileSDCache := cache.New()\n\n\t// Perform initial DNS resolution before starting periodic updates.\n\t// This ensures that DNS providers have addresses when the first endpoint update runs.\n\t{\n\t\tresolveCtx, resolveCancel := context.WithTimeout(context.Background(), dnsSDInterval)\n\t\tdefer resolveCancel()\n\n\t\tlevel.Info(logger).Log(\"msg\", \"performing initial DNS resolution for endpoints\")\n\n\t\tendpointConfig := configProvider.config()\n\t\taddresses := make([]string, 0, len(endpointConfig.Endpoints))\n\t\tfor _, ecfg := range endpointConfig.Endpoints {\n\t\t\t// Only resolve non-group dynamic endpoints here.\n\t\t\t// Group endpoints are resolved by the gRPC resolver in its Build() method.\n\t\t\tif addr := ecfg.Address; dns.IsDynamicNode(addr) && !ecfg.Group {","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/endpointset.go#L348-L384","documentation":"Raised when Thanos cannot instantiate the Prometheus common file-based service discovery (file.SDConfig) used for legacy endpoint files. The file discovery component watches legacy file_sd lists of store endpoints; construction failure (invalid config, metrics registry issues) aborts setupEndpointSet with this wrapped error.","triggerScenarios":"file.NewDiscovery returns error after building SDConfig from --store-file-sd-* legacy flags (files list, refresh interval) and its discoverer metrics; e.g., nil registry, invalid RefreshInterval, or internal prometheus/common/discovery construction failure.","commonSituations":"Running legacy --store-file-sd flag paths with an incompatible prometheus/common version after an upgrade; refresh interval formatted incorrectly via model.Duration; registry/metrics registration collision.","solutions":["Check the inner error from file.NewDiscovery; typically fix the legacy file SD flags (--store-file-sd) values (existing files list, valid refresh interval like 5m).","Prefer the modern --endpoint-config / --endpoint-group-config mechanism over legacy file SD; migrate and remove legacy flags.","Ensure the referenced file_sd files exist and contain a JSON list of targets; empty/nonexistent files are tolerated by watcher but check flags anyway.","Upgrade/downgrade Thanos so prometheus/common discovery API matches; the error often indicates version skew."],"exampleFix":"// before: legacy flags with bad interval\n// --store-file-sd-refresh-interval=0s --store-file-sd=/etc/thanos/stores.json\n// after\n// --store-file-sd-refresh-interval=5m --store-file-sd=/etc/thanos/stores.json\n// (or migrate) --endpoint-config=/etc/thanos/endpoints.yaml","handlingStrategy":"fallback","validationCode":"for _, f := range legacyFileSDFiles { if _, err := os.Stat(f); err != nil { return fmt.Errorf(\"file_sd file missing: %s\", f) } }","typeGuard":"func legacySDConfigured(files []string, interval model.Duration) bool { return len(files) > 0 && interval > 0 }","tryCatchPattern":"fileSD, err = file.NewDiscovery(conf, slogLogger, metrics)\nif err != nil {\n    logger.Warn(\"legacy file SD unavailable, continuing with static endpoints\", \"err\", err)\n    fileSD = nil\n}","preventionTips":["Migrate off legacy --store-file-sd flags to --endpoint-config.","Verify prometheus/common version matches your Thanos build after upgrades.","Use valid model.Duration values for refresh interval.","Ensure referenced file_sd files exist and are valid JSON lists."],"tags":["service-discovery","config","thanos","legacy"],"backgroundTag":"invalid-config-value","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"}