{"id":"c348913181bce199","repo":"go-redis/redis","slug":"relaxed-timeout-must-be-greater-than-0","errorCode":null,"errorMessage":"relaxed timeout must be greater than 0","messagePattern":"relaxed timeout must be greater than 0","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"maintnotifications/errors.go","lineNumber":11,"sourceCode":"package maintnotifications\n\nimport (\n\t\"errors\"\n\n\t\"github.com/redis/go-redis/v9/internal/maintnotifications/logs\"\n)\n\n// Configuration errors\nvar (\n\tErrInvalidRelaxedTimeout             = errors.New(logs.InvalidRelaxedTimeoutError())\n\tErrInvalidHandoffTimeout             = errors.New(logs.InvalidHandoffTimeoutError())\n\tErrInvalidHandoffWorkers             = errors.New(logs.InvalidHandoffWorkersError())\n\tErrInvalidHandoffQueueSize           = errors.New(logs.InvalidHandoffQueueSizeError())\n\tErrInvalidPostHandoffRelaxedDuration = errors.New(logs.InvalidPostHandoffRelaxedDurationError())\n\tErrInvalidEndpointType               = errors.New(logs.InvalidEndpointTypeError())\n\tErrInvalidMaintNotifications         = errors.New(logs.InvalidMaintNotificationsError())\n\tErrMaxHandoffRetriesReached          = errors.New(logs.MaxHandoffRetriesReachedError())\n\n\t// Configuration validation errors\n\n\t// ErrInvalidHandoffRetries is returned when the number of handoff retries is invalid\n\tErrInvalidHandoffRetries = errors.New(logs.InvalidHandoffRetriesError())\n)\n\n// Integration errors\nvar (\n\t// ErrInvalidClient is returned when the client does not support push notifications\n\tErrInvalidClient = errors.New(logs.InvalidClientError())","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/maintnotifications/errors.go#L1-L29","documentation":"maintnotifications.ErrInvalidRelaxedTimeout (message: \"relaxed timeout must be greater than 0\") is returned by Config.Validate() when RelaxedTimeout <= 0 (config.go:158-160). RelaxedTimeout governs the extended read/write deadlines applied during MIGRATING/FAILING_OVER so in-flight ops survive increased latency; it must be a positive duration. (When defaults are applied via merge, a zero value is replaced by the 10s default, so this error only surfaces when Validate runs on a raw config with a non-positive value.)","triggerScenarios":"Constructing maintnotifications.Config with RelaxedTimeout set to 0 or negative and calling cfg.Validate() (directly or via the client setup that validates) before/without default-merging.","commonSituations":"Explicitly zeroing the config struct, copy-pasting a partial config, or a negative value from an env-driven calculation that underflowed.","solutions":["Set RelaxedTimeout to a positive duration (e.g. 10*time.Second, the default).","Use DefaultConfig()/merge-with-defaults so a zero value is filled in rather than rejected.","Validate computed config values before assigning (guard against <= 0 from arithmetic)."],"exampleFix":"// before\ncfg := &maintnotifications.Config{RelaxedTimeout: 0}\ncfg.Validate() // errors\n// after\ncfg := maintnotifications.DefaultConfig()\ncfg.RelaxedTimeout = 10 * time.Second","handlingStrategy":"validation","validationCode":"cfg := maintnotifications.DefaultConfig()\nif envRelaxed > 0 {\n    cfg.RelaxedTimeout = time.Duration(envRelaxed) * time.Second\n} // never assign a non-positive value\ncfg.Validate()","typeGuard":"func validRelaxedTimeout(d time.Duration) bool {\n    return d > 0\n}","tryCatchPattern":"if err := cfg.Validate(); err != nil {\n    if errors.Is(err, maintnotifications.ErrInvalidRelaxedTimeout) {\n        cfg.RelaxedTimeout = 10 * time.Second // fall back to default\n    } else {\n        return err\n    }\n}","preventionTips":["Start from DefaultConfig() so zeros are filled, not rejected.","Guard env-driven duration arithmetic against <= 0.","Validate config once at startup, not per request."],"tags":["maintnotifications","configuration","validation","timeout"],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}