{"record":{"id":"08a202bfc4c20e44","repo":"router-for-me/CLIProxyAPI","slug":"create-downstream-audio-track-w","errorCode":null,"errorMessage":"create downstream audio track: %w","messagePattern":"create downstream audio track: %w","errorType":"http","errorClass":null,"httpStatus":502,"severity":"error","filePath":"internal/client/codex/live/media.go","lineNumber":332,"sourceCode":"\t}\n\tsession.bridge = newDataChannelBridge(session.done, func(err error) {\n\t\tsession.fail(\"data_channel_failed\", err)\n\t})\n\tsession.installStateHandlers()\n\tlog.WithFields(session.logFields(\"session\")).Info(\"codex live WebRTC media session created\")\n\n\tif errRemote := downstream.SetRemoteDescription(webrtc.SessionDescription{\n\t\tType: webrtc.SDPTypeOffer,\n\t\tSDP:  clientOffer,\n\t}); errRemote != nil {\n\t\t_ = session.Close()\n\t\treturn nil, \"\", fmt.Errorf(\"set downstream WebRTC offer: %w\", errRemote)\n\t}\n\n\ttoDesktop, errTrack := webrtc.NewTrackLocalStaticRTP(opusCodec, \"audio\", \"codex-live\")\n\tif errTrack != nil {\n\t\t_ = session.Close()\n\t\treturn nil, \"\", fmt.Errorf(\"create downstream audio track: %w\", errTrack)\n\t}\n\tdownstreamSender, errTrack := downstream.AddTrack(toDesktop)\n\tif errTrack != nil {\n\t\t_ = session.Close()\n\t\treturn nil, \"\", fmt.Errorf(\"add downstream audio track: %w\", errTrack)\n\t}\n\tgo drainRTCP(\"downstream\", downstreamSender, session.done)\n\n\ttoOpenAI, errTrack := webrtc.NewTrackLocalStaticRTP(opusCodec, \"audio\", \"codex-live\")\n\tif errTrack != nil {\n\t\t_ = session.Close()\n\t\treturn nil, \"\", fmt.Errorf(\"create upstream audio track: %w\", errTrack)\n\t}\n\tupstreamSender, errTrack := upstream.AddTrack(toOpenAI)\n\tif errTrack != nil {\n\t\t_ = session.Close()\n\t\treturn nil, \"\", fmt.Errorf(\"add upstream audio track: %w\", errTrack)\n\t}","sourceCodeStart":314,"sourceCodeEnd":350,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/client/codex/live/media.go#L314-L350","documentation":"Thrown when webrtc.NewTrackLocalStaticRTP(opusCodec, \"audio\", \"codex-live\") fails for the downstream (client-facing) track. With a static capability this constructor essentially cannot fail in current pion v4 — it validates the codec capability (must have MimeType, ClockRate > 0). Failure means the opusCodec constant is malformed or a pion version changed validation rules.","triggerScenarios":"A pion/webrtc upgrade that tightens TrackLocalStaticRTP validation, or a code change to the opusCodec variable (e.g. zero ClockRate or empty MimeType).","commonSituations":"Practically unreachable with the shipped constants; appears only after hand-editing opusCodec or a major pion version bump.","solutions":["Restore opusCodec to MimeTypeOpus / ClockRate 48000 / Channels 2","Pin/align pion/webrtc v4 to a tested version after upgrades","Treat as a code defect — no runtime config influences this path"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never modify the opusCodec shared constant","Pin pion/webrtc v4 to a tested release and retest on upgrades","Treat occurrence as a build-time defect, not runtime drift"],"tags":["webrtc","pion","audio","track","unreachable-in-practice"],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}