{"record":{"id":"d243aa3232203eb1","repo":"jaegertracing/jaeger","slug":"max-search-depth-must-be-a-positive-number","errorCode":null,"errorMessage":"max_search_depth must be a positive number","messagePattern":"max_search_depth must be a positive number","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/v2/clickhouse/config.go","lineNumber":94,"sourceCode":"}\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":76,"sourceCodeEnd":104,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/storage/v2/clickhouse/config.go#L76-L104","documentation":"ClickHouse Configuration.Validate returns this error when MaxSearchDepth is zero or negative. Like DefaultSearchDepth, a non-positive max depth would make trace searches return nothing or be meaningless, so it is rejected up front.","triggerScenarios":"Creating a ClickHouse reader with MaxSearchDepth <= 0, typically when the field is left at its zero value in the Configuration.","commonSituations":"Partial config files omitting max_search_depth; constructing Configuration programmatically without setting it; assuming DefaultSearchDepth alone is sufficient.","solutions":["Set max_search_depth to a positive integer greater than or equal to default_search_depth","Apply sane defaults when loading configuration","Run Validate before instantiating the reader so misconfiguration fails fast"],"exampleFix":"// before\ncfg.MaxSearchDepth = 0\n// after\ncfg.MaxSearchDepth = 1000","handlingStrategy":"validation","validationCode":"if cfg.MaxSearchDepth <= 0 {\n    return errors.New(\"max_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(), \"max_search_depth must be a positive number\") {\n        cfg.MaxSearchDepth = 1000\n    }\n}","preventionTips":["Set MaxSearchDepth >= DefaultSearchDepth when loading config","Never ship a Configuration struct with unset depth fields","Include Validate in smoke tests for deployment configs"],"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"}