{"record":{"id":"2e4e60f8d67e667f","repo":"router-for-me/CLIProxyAPI","slug":"create-upstream-audio-track-w","errorCode":null,"errorMessage":"create upstream audio track: %w","messagePattern":"create upstream audio track: %w","errorType":"http","errorClass":null,"httpStatus":502,"severity":"error","filePath":"internal/client/codex/live/media.go","lineNumber":344,"sourceCode":"\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}\n\tgo drainRTCP(\"upstream\", upstreamSender, session.done)\n\n\tdownstream.OnTrack(func(track *webrtc.TrackRemote, _ *webrtc.RTPReceiver) {\n\t\tif !strings.EqualFold(track.Codec().MimeType, webrtc.MimeTypeOpus) {\n\t\t\treturn\n\t\t}\n\t\tgo relayRTP(\"downstream-to-upstream\", track, toOpenAI, session.done)\n\t})\n\tupstream.OnTrack(func(track *webrtc.TrackRemote, _ *webrtc.RTPReceiver) {\n\t\tif !strings.EqualFold(track.Codec().MimeType, webrtc.MimeTypeOpus) {\n\t\t\treturn\n\t\t}","sourceCodeStart":326,"sourceCodeEnd":362,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/client/codex/live/media.go#L326-L362","documentation":"Same constructor as error 326 but for the upstream (OpenAI-facing) track toOpenAI. NewTrackLocalStaticRTP with the shared opusCodec capability; failure semantics are identical — malformed capability or a pion validation change. Not influenced by network or negotiation state.","triggerScenarios":"Identical to 326: modified opusCodec constant or pion/webrtc version behavior change.","commonSituations":"Unreachable with shipped constants; a defensive error path kept for API-contract safety.","solutions":["Restore opusCodec constants (MimeTypeOpus, 48000, 2 channels)","Pin pion/webrtc version; treat occurrence as a build/code defect"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep opusCodec constants immutable and shared between both tracks","Run the media relay unit tests after any pion version bump"],"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"}