{"record":{"id":"255d2be68ca14dfe","repo":"thanos-io/thanos","slug":"labels-default-time-range-cannot-be-set-to-0","errorCode":null,"errorMessage":"labels.default-time-range cannot be set to 0","messagePattern":"labels\\.default-time-range cannot be set to 0","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/queryfrontend/config.go","lineNumber":297,"sourceCode":"\n\tif cfg.isDynamicSplitSet() {\n\n\t\tif err := cfg.validateDynamicSplitParams(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif cfg.LabelsConfig.ResultsCacheConfig != nil {\n\t\tif cfg.LabelsConfig.SplitQueriesByInterval <= 0 {\n\t\t\treturn errors.New(\"split queries interval should be greater than 0  when caching is enabled\")\n\t\t}\n\t\tif err := cfg.LabelsConfig.ResultsCacheConfig.Validate(querier.Config{}); err != nil {\n\t\t\treturn errors.Wrap(err, \"invalid ResultsCache config for labels tripperware\")\n\t\t}\n\t}\n\n\tif cfg.DefaultTimeRange == 0 {\n\t\treturn errors.New(\"labels.default-time-range cannot be set to 0\")\n\t}\n\n\tif cfg.DownstreamURL == \"\" {\n\t\treturn errors.New(\"downstream URL should be configured\")\n\t}\n\n\treturn nil\n}\n\nfunc (cfg *Config) validateDynamicSplitParams() error {\n\tif cfg.HorizontalShards <= 0 {\n\t\treturn errors.New(\"min horizontal shards should be greater than 0 when query split threshold is enabled\")\n\t}\n\n\tif cfg.MaxQuerySplitInterval <= 0 {\n\t\treturn errors.New(\"max query split interval should be greater than 0 when query split threshold is enabled\")\n\t}\n","sourceCodeStart":279,"sourceCodeEnd":315,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/queryfrontend/config.go#L279-L315","documentation":"The query-frontend requires labels.default-time-range to be explicitly set to a non-zero duration. This value is used as the default end-time range for label queries, so a zero value is treated as an unconfigured/invalid config. Validate() rejects it during startup.","triggerScenarios":"Config.Validate is called where cfg.DefaultTimeRange == 0 — i.e. labels.default-time-range was never set in the YAML/flags or was explicitly set to 0.","commonSituations":"New deployments that enable the labels tripperware but forget the required labels.default-time-range flag; config files migrated from setups that did not use the labels tripperware; setting the flag to 0 assuming it means 'unlimited'.","solutions":["Set labels.default-time-range to a positive duration (e.g. 24h) in the config or via the -labels.default-time-range flag","If you intended unlimited ranges, pick a sane upper bound instead of 0","Re-run config validation before restarting"],"exampleFix":"// before\nlabels:\n  default-time-range: 0s\n// after\nlabels:\n  default-time-range: 24h","handlingStrategy":"validation","validationCode":"if cfg.DefaultTimeRange == 0 {\n    return errors.New(\"set labels.default-time-range to a positive duration\")\n}","typeGuard":"func defaultTimeRangeSet(d time.Duration) bool { return d > 0 }","tryCatchPattern":"if err := cfg.Validate(); err != nil {\n    if strings.Contains(err.Error(), \"default-time-range\") {\n        log.Fatalf(\"labels.default-time-range must be > 0: %v\", err)\n    }\n}","preventionTips":["Always set labels.default-time-range when enabling any labels tripperware feature","Treat 0 as invalid, not as 'unlimited'","Add a startup smoke test that loads the production config and calls Validate"],"tags":["config","validation","query-frontend","labels"],"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"}