- Notifications
You must be signed in to change notification settings - Fork210
fix(voice): raise FileNotFoundError for missing local path innextcord.FFmpegPCMAudio#1272
fix(voice): raise FileNotFoundError for missing local path innextcord.FFmpegPCMAudio#1272Dking08 wants to merge 6 commits intonextcord:masterfrom
nextcord.FFmpegPCMAudio#1272Conversation
4fc607c tob717021Comparenextcord.FFmpegPCMAudio (#1229)nextcord.FFmpegPCMAudioteaishealthy commentedOct 24, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
works, but im not sure if this is the right approach for this, it seems flaky. it's probably a better idea to leave the task of checking if a file exists to the user. somewhat confusingly nothing in the codebase ever checks the exit code of ffmpeg ever. some thoughts: we could add something like has_failed to VoiceClient and AudioPlayer so the user could actually check why the client stopped. |
Dking08 commentedOct 25, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@teaishealthy Thanks for the detailed feedback! |
- Remove unreliable file path validation- Add _raise_if_process_failed() method to check ffmpeg exit codes- Expose AudioPlayer.error and has_failed properties- Raise ClientException in read() when ffmpeg exits with non-zero statusReplaces flaky proactive file checks with robust error detection.
003111f tof60ac18CompareUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: teaishealthy <76410798+teaishealthy@users.noreply.github.com>
Dking08 commentedOct 30, 2025
@teaishealthy |
Uh oh!
There was an error while loading.Please reload this page.
Summary
Detect and surface ffmpeg failures via exit code checking.
FFmpegPCMAudio,FFmpegOpusAudio(via FFmpegAudio base),AudioPlayer_raise_if_process_failed()method to check ffmpeg exit codesFFmpeg*Audio.read()when stream ends unexpectedlyAudioPlayer.errorandAudioPlayer.has_failedproperties for error inspectionFFmpegPCMAudiodocstring to document runtime error behaviorBehavioral impact:
ClientExceptionwith exit code information during playbackAudioPlayer.has_failedandAudioPlayer.errorto inspect playback failuresIf applicable, link issue(s):
nextcord.FFmpegPCMAudiodoes not throw FileNotFoundError #1229Initial Approach(Revised - see below)Click to view original approach (replaced with more robust solution)
Original approach: Proactive file existence checking
The initial implementation added early file existence validation in
FFmpegAudio.__init__using a_looks_like_local_path()helper to distinguish local files from URLs/virtual inputs.Why it was changed:
Revised approach: Reactive error detection via exit codes
Reproduction and verification
Minimal example:
Expected:
ClientExceptionraised during.read()when ffmpeg exits with non-zero status, error accessible via AudioPlayer properties.Additional notes:
FFmpegPCMAudioandFFmpegOpusAudiobenefit from this error handlingThis is a Code Change
task pyrightand fixed the relevant issues.Tooling status
task lint)poetry run python -m pyright→ 0 errors)task slotscheck)Risk assessment
Low. Changes improve error visibility by detecting actual ffmpeg failures rather than attempting flaky proactive validation. Error information is now accessible to users via clean API.