{"record":{"id":"d579a27867515534","repo":"router-for-me/CLIProxyAPI","slug":"codex-live-media-relay-max-sessions-must-not-be-ne","errorCode":null,"errorMessage":"codex.live-media-relay.max-sessions must not be negative","messagePattern":"codex\\.live-media-relay\\.max-sessions must not be negative","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/config/codex_live.go","lineNumber":71,"sourceCode":"\t*c = CodexLiveMediaRelayConfig(decoded)\n\treturn nil\n}\n\n// EffectiveMaxSessions returns the configured media session limit.\nfunc (c CodexLiveMediaRelayConfig) EffectiveMaxSessions() int {\n\tif c.MaxSessions > 0 {\n\t\treturn c.MaxSessions\n\t}\n\treturn DefaultCodexLiveMediaMaxSessions\n}\n\n// Validate verifies the Codex Live media relay configuration.\nfunc (c CodexLiveMediaRelayConfig) Validate() error {\n\tif !c.Enabled {\n\t\treturn nil\n\t}\n\tif c.MaxSessions < 0 {\n\t\treturn errors.New(\"codex.live-media-relay.max-sessions must not be negative\")\n\t}\n\tif publicIP := strings.TrimSpace(c.PublicIP); publicIP != \"\" && net.ParseIP(publicIP) == nil {\n\t\treturn fmt.Errorf(\"codex.live-media-relay.public-ip is invalid: %q\", publicIP)\n\t}\n\tif (c.UDPPortMin == 0) != (c.UDPPortMax == 0) {\n\t\treturn errors.New(\"codex.live-media-relay UDP port minimum and maximum must both be set\")\n\t}\n\tif c.UDPPortMin > c.UDPPortMax {\n\t\treturn errors.New(\"codex.live-media-relay.udp-port-min must not exceed udp-port-max\")\n\t}\n\tif c.UDPPortMin != 0 {\n\t\tavailablePorts := int(c.UDPPortMax) - int(c.UDPPortMin) + 1\n\t\trequiredPorts := c.EffectiveMaxSessions() * 2\n\t\tif availablePorts < requiredPorts {\n\t\t\treturn fmt.Errorf(\"codex.live-media-relay UDP range requires at least %d ports for %d sessions\", requiredPorts, c.EffectiveMaxSessions())\n\t\t}\n\t}\n\tfor serverIndex, server := range c.ICEServers {","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/config/codex_live.go#L53-L89","documentation":"Validation error for the codex.live-media-relay config: enabled is true and max-sessions was set to a negative number. Negative session limits are meaningless (zero already means 'use the default'), so Validate() rejects them before the relay starts.","triggerScenarios":"Config with codex.live-media-relay.enabled: true and max-sessions: -1 (or any negative value).","commonSituations":"Typo in config, or copied snippets using -1 as an 'unlimited' convention from other tools.","solutions":["Set max-sessions to a positive limit, or remove the key / set 0 to use DefaultCodexLiveMediaMaxSessions","Re-validate the config and restart"],"exampleFix":"# before\ncodex:\n  live-media-relay:\n    enabled: true\n    max-sessions: -1\n# after\ncodex:\n  live-media-relay:\n    enabled: true\n    max-sessions: 16","handlingStrategy":"validation","validationCode":"if cfg.Codex.LiveMediaRelay.Enabled && cfg.Codex.LiveMediaRelay.MaxSessions < 0 {\n    return fmt.Errorf(\"reject config: max-sessions=%d is negative\", cfg.Codex.LiveMediaRelay.MaxSessions)\n}","typeGuard":null,"tryCatchPattern":"if err := relayCfg.Validate(); err != nil {\n    if strings.Contains(err.Error(), \"max-sessions must not be negative\") {\n        return errors.New(\"config fix: set max-sessions >= 0 (0 = default limit)\")\n    }\n    return err\n}","preventionTips":["Use 0 for the default limit instead of -1","Run config validation in CI with the same binary version that serves production"],"tags":["config","validation","codex","media-relay"],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}