{"record":{"id":"ff63f732b2378a5c","repo":"SigNoz/signoz","slug":"codeinvalidinput-ff63f7","errorCode":"CodeInvalidInput","errorMessage":"lifetime::idle must not be negative","messagePattern":"lifetime::idle must not be negative","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"pkg/tokenizer/config.go","lineNumber":98,"sourceCode":"\t\t},\n\t\tJWT: JWTConfig{\n\t\t\tSecret: \"\",\n\t\t},\n\t\tRotation: RotationConfig{\n\t\t\tInterval: 30 * time.Minute, // 30 minutes\n\t\t\tDuration: 60 * time.Second, // 60 seconds\n\t\t},\n\t\tLifetime: LifetimeConfig{\n\t\t\tIdle: 7 * 24 * time.Hour,  // 7 days\n\t\t\tMax:  30 * 24 * time.Hour, // 30 days\n\t\t},\n\t}\n}\n\nfunc (c Config) Validate() error {\n\t// Ensure that lifetime idle is not negative\n\tif c.Lifetime.Idle < 0 {\n\t\treturn errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, \"lifetime::idle must not be negative\")\n\t}\n\n\t// Ensure that lifetime max is not negative\n\tif c.Lifetime.Max < 0 {\n\t\treturn errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, \"lifetime::max must not be negative\")\n\t}\n\n\t// Ensure that rotation interval is smaller than lifetime idle\n\tif c.Rotation.Interval >= c.Lifetime.Idle {\n\t\treturn errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, \"rotation::interval must be smaller than lifetime::idle\")\n\t}\n\n\t// Ensure that lifetime idle interval is smaller than lifetime max\n\tif c.Lifetime.Idle >= c.Lifetime.Max {\n\t\treturn errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, \"lifetime::idle must be smaller than lifetime::max\")\n\t}\n\n\t// Ensure that rotation duration is smaller than rotation interval","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/tokenizer/config.go#L80-L116","documentation":"tokenizer Config.Validate rejects negative Lifetime.Idle values. Lifetime.Idle controls how long idle tokens may live; a negative duration is nonsensical and is treated as invalid configuration before the tokenizer starts.","triggerScenarios":"Constructing tokenizer.Config with Lifetime.Idle < 0, e.g. by parsing a negative number from a config file or env var into the time.Duration field.","commonSituations":"Env var parsed as '-1' meaning 'unlimited' by convention but mapped directly to Duration, YAML misconfiguration, or zero-value struct combined with arithmetic that goes negative.","solutions":["Set Lifetime.Idle to 0 or a positive duration (use 0 to mean no idle limit if that is the semantic)","Validate config at startup via Config.Validate() so the error surfaces immediately","Fix the config source producing the negative value (env parser, YAML)"],"exampleFix":"// before\ncfg := tokenizer.Config{Lifetime: tokenizer.Lifetime{Idle: -1 * time.Second}}\n\n// after\ncfg := tokenizer.Config{Lifetime: tokenizer.Lifetime{Idle: 30 * time.Minute}}","handlingStrategy":"validation","validationCode":"if err := cfg.Validate(); err != nil {\n    log.Fatal(err)\n}","typeGuard":null,"tryCatchPattern":"if err := cfg.Validate(); err != nil {\n    return fmt.Errorf(\"invalid tokenizer config: %w\", err)\n}","preventionTips":["Reject negative durations at the config-parsing layer","Treat 'unlimited' as explicit zero, never -1, in configuration conventions"],"tags":["go","tokenizer","config-validation","lifetime"],"backgroundTag":"config-validation-failed","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}