{"record":{"id":"2ea192c6bc72135f","repo":"thanos-io/thanos","slug":"split-queries-or-split-threshold-interval-should-b","errorCode":null,"errorMessage":"split queries or split threshold interval should be greater than 0 when caching is enabled","messagePattern":"split queries or split threshold interval should be greater than 0 when caching is enabled","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/queryfrontend/config.go","lineNumber":264,"sourceCode":"\t// PartialResponseStrategy is the default strategy used\n\t// when parsing thanos query request.\n\tPartialResponseStrategy bool\n\tDefaultTimeRange        time.Duration\n\n\tResultsCacheConfig *queryrange.ResultsCacheConfig\n\tCachePathOrContent extflag.PathOrContent\n\n\tSplitQueriesByInterval time.Duration\n\tMaxRetries             int\n\n\tLimits *cortexvalidation.Limits\n}\n\n// Validate a fully initialized config.\nfunc (cfg *Config) Validate() error {\n\tif cfg.QueryRangeConfig.ResultsCacheConfig != nil {\n\t\tif cfg.QueryRangeConfig.SplitQueriesByInterval <= 0 && !cfg.isDynamicSplitSet() {\n\t\t\treturn errors.New(\"split queries or split threshold interval should be greater than 0 when caching is enabled\")\n\t\t}\n\t\t// This is instantiated just to make the QFE config comply with validation against the Cortex Querier,\n\t\t// but in Thanos we don't use this configuration at all.\n\t\tignoredQueryConfig := querier.Config{\n\t\t\tEnablePerStepStats: cfg.QueryRangeConfig.ResultsCacheConfig.CacheQueryableSamplesStats,\n\t\t}\n\t\tif err := cfg.QueryRangeConfig.ResultsCacheConfig.Validate(ignoredQueryConfig); err != nil {\n\t\t\treturn errors.Wrap(err, \"invalid ResultsCache config for query_range tripperware\")\n\t\t}\n\t}\n\n\tif cfg.isDynamicSplitSet() && cfg.isStaticSplitSet() {\n\t\treturn errors.New(\"split queries interval and dynamic query split interval cannot be set at the same time\")\n\t}\n\n\tif cfg.isDynamicSplitSet() {\n\n\t\tif err := cfg.validateDynamicSplitParams(); err != nil {","sourceCodeStart":246,"sourceCodeEnd":282,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/queryfrontend/config.go#L246-L282","documentation":"Config.Validate enforces that when the query_range results cache is enabled, queries are split into cacheable chunks: either a static QueryRangeConfig.SplitQueriesByInterval > 0 or a dynamic split threshold must be set. Otherwise caching cannot work and validation returns this error at frontend startup.","triggerScenarios":"QueryRangeConfig.ResultsCacheConfig is non-nil (caching enabled) while SplitQueriesByInterval <= 0 and isDynamicSplitSet() returns false (no dynamic split threshold configured).","commonSituations":"Operator enables response caching via --query-range.response-cache-config but forgets --query-range.split-queries-by-interval, or sets it to 0/negative after a version upgrade where defaults changed.","solutions":["Set --query-range.split-queries-by-interval to a positive duration (e.g. 1d).","Or enable dynamic query splitting with a positive --query-range.dynamic-split-threshold so isDynamicSplitSet() is true.","Or disable the results cache if splitting is not desired."],"exampleFix":"// before\nqueryRangeFlags := []string{\"--query-range.response-cache-config-file=cache.yml\"}\n// after\nqueryRangeFlags := []string{\"--query-range.response-cache-config-file=cache.yml\", \"--query-range.split-queries-by-interval=24h\"}","handlingStrategy":"validation","validationCode":"// before startup\nif cachingEnabled && splitInterval <= 0 && dynamicSplitThreshold <= 0 {\n    return errors.New(\"enable --query-range.split-queries-by-interval or --query-range.dynamic-split-threshold when response caching is on\")\n}","typeGuard":null,"tryCatchPattern":"if err := cfg.Validate(); err != nil {\n    if strings.Contains(err.Error(), \"split queries or split threshold\") {\n        return fmt.Errorf(\"add a split flag when caching is enabled: %w\", err)\n    }\n    return err\n}","preventionTips":["Always pair --query-range.response-cache-config with --query-range.split-queries-by-interval.","Add a smoke test that runs the frontend with production flags in CI.","Re-check flags after Thanos upgrades for changed defaults."],"tags":["config","validation","caching","query-frontend"],"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"}