{"record":{"id":"5cc80b7217407e9d","repo":"jaegertracing/jaeger","slug":"default-search-depth-must-be-a-positive-number","errorCode":null,"errorMessage":"default_search_depth must be a positive number","messagePattern":"default_search_depth must be a positive number","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/v2/clickhouse/config.go","lineNumber":91,"sourceCode":"\t\tAttributeMetadataCacheTTL:     defaultAttributeMetadataCacheTTL,\n\t\tAttributeMetadataCacheMaxSize: defaultAttributeMetadataCacheMaxSize,\n\t}\n}\n\nfunc (cfg *Configuration) Validate() error {\n\tif _, err := govalidator.ValidateStruct(cfg); err != nil {\n\t\treturn err\n\t}\n\tif cfg.TTL < 0 {\n\t\treturn errors.New(\"ttl must be a non-negative duration\")\n\t}\n\tif cfg.TTL > 0 && cfg.TTL%time.Second != 0 {\n\t\treturn errors.New(\"ttl must be a whole number of seconds\")\n\t}\n\t// A search depth of zero would make every trace search return nothing, and a\n\t// negative one is meaningless, so reject both rather than querying with them.\n\tif cfg.DefaultSearchDepth <= 0 {\n\t\treturn errors.New(\"default_search_depth must be a positive number\")\n\t}\n\tif cfg.MaxSearchDepth <= 0 {\n\t\treturn errors.New(\"max_search_depth must be a positive number\")\n\t}\n\tif cfg.AttributeMetadataCacheTTL < 0 {\n\t\treturn errors.New(\"attribute_metadata_cache_ttl must be a non-negative duration\")\n\t}\n\tif cfg.AttributeMetadataCacheMaxSize < 0 {\n\t\treturn errors.New(\"attribute_metadata_cache_max_size must be a non-negative number\")\n\t}\n\treturn nil\n}\n","sourceCodeStart":73,"sourceCodeEnd":104,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/storage/v2/clickhouse/config.go#L73-L104","documentation":"ClickHouse Configuration.Validate returns this error when DefaultSearchDepth is zero or negative. A search depth of zero would make every trace search return nothing and a negative one is meaningless, so both are rejected rather than producing empty results.","triggerScenarios":"Creating a ClickHouse reader with DefaultSearchDepth <= 0 in the Configuration, surfaced via Validate.","commonSituations":"Zero-value Configuration structs passed to the factory without setting required fields; config files missing default_search_depth; code assuming a default of 0 means \"unlimited\".","solutions":["Set default_search_depth to a positive integer (e.g. the maximum plausible trace depth)","Provide defaults at config-load time instead of relying on the zero value","Add a Validate call in your bootstrap path so the error is caught before serving traffic"],"exampleFix":"// before\ncfg.DefaultSearchDepth = 0\n// after\ncfg.DefaultSearchDepth = 1000","handlingStrategy":"validation","validationCode":"if cfg.DefaultSearchDepth <= 0 {\n    return errors.New(\"default_search_depth must be a positive number\")\n}","typeGuard":"func validDepth(n int) bool { return n > 0 }","tryCatchPattern":"if err := cfg.Validate(); err != nil {\n    if strings.Contains(err.Error(), \"default_search_depth must be a positive number\") {\n        cfg.DefaultSearchDepth = 1000\n    }\n}","preventionTips":["Always set DefaultSearchDepth explicitly; never rely on zero values","Provide defaults in the config loader","Run Validate in startup tests"],"tags":["clickhouse","configuration","search","jaeger"],"backgroundTag":"invalid-config-value","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}