{"record":{"id":"30e531e5454f4c2d","repo":"router-for-me/CLIProxyAPI","slug":"codex-live-media-relay-udp-port-minimum-and-maximu","errorCode":null,"errorMessage":"codex.live-media-relay UDP port minimum and maximum must both be set","messagePattern":"codex\\.live-media-relay UDP port minimum and maximum must both be set","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/config/codex_live.go","lineNumber":77,"sourceCode":"\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 {\n\t\tif len(server.URLs) == 0 {\n\t\t\treturn fmt.Errorf(\"codex.live-media-relay.ice-servers[%d].urls is required\", serverIndex)\n\t\t}\n\t\tfor _, rawURL := range server.URLs {\n\t\t\tparsed, errParse := url.Parse(strings.TrimSpace(rawURL))\n\t\t\tif errParse != nil || parsed.Scheme == \"\" {","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/config/codex_live.go#L59-L95","documentation":"Validation error for codex.live-media-relay: exactly one of udp-port-min / udp-port-max was set (the other left at 0). The UDP port range must be either fully unset (ephemeral ports) or fully specified, because the relay reserves a contiguous range for its sessions (two ports per session).","triggerScenarios":"Config with enabled: true and only udp-port-min or only udp-port-max present.","commonSituations":"Partially filled config from documentation examples; someone sets only the lower bound expecting a half-open range.","solutions":["Set both udp-port-min and udp-port-max (e.g. 50000 and 50100), or remove both","Ensure the range has at least 2 * max-sessions ports available or validation fails with the follow-on range-size error"],"exampleFix":"# before\ncodex:\n  live-media-relay:\n    enabled: true\n    udp-port-min: 50000\n# after\ncodex:\n  live-media-relay:\n    enabled: true\n    udp-port-min: 50000\n    udp-port-max: 50100","handlingStrategy":"validation","validationCode":"r := cfg.Codex.LiveMediaRelay\nif r.Enabled && (r.UDPPortMin == 0) != (r.UDPPortMax == 0) {\n    return errors.New(\"udp-port-min and udp-port-max must be set together\")\n}","typeGuard":null,"tryCatchPattern":"if err := relayCfg.Validate(); err != nil {\n    if strings.Contains(err.Error(), \"must both be set\") {\n        return errors.New(\"config fix: set both udp-port-min and udp-port-max, or neither\")\n    }\n    return err\n}","preventionTips":["Copy the full udp-port-min/udp-port-max pair from config.example.yaml","Automate config generation instead of hand-editing ranges"],"tags":["config","validation","codex","media-relay","udp"],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}