Skip to content

Comments

Include file path in audio loading error messages#4175

Open
Mr-Neutr0n wants to merge 1 commit intopytorch:mainfrom
Mr-Neutr0n:fix-load-error-messages
Open

Include file path in audio loading error messages#4175
Mr-Neutr0n wants to merge 1 commit intopytorch:mainfrom
Mr-Neutr0n:fix-load-error-messages

Conversation

@Mr-Neutr0n
Copy link

Summary

  • When torchaudio.load() fails on a file, the error message now includes the file path/URI that caused the failure
  • Updated error messages in load_with_torchcodec() for sample rate detection and audio decoding failures to include the URI
  • Added a catch-all try/except in torchaudio.load() that ensures any unexpected exception also surfaces the file path

Fixes #3810

Test plan

  • Call torchaudio.load() with a non-existent file path and verify the error message includes the file path
  • Call torchaudio.load() with a corrupted/invalid audio file and verify the error message includes the file path
  • Call torchaudio.load() with a valid audio file and verify it still works correctly
  • Verify that error messages from load_with_torchcodec() that already contain the URI are not duplicated

When torchaudio.load() fails, the error message now indicates which file
was being loaded. This helps users diagnose issues when loading multiple
files in batch processing pipelines.

Fixes pytorch#3810
@Mr-Neutr0n Mr-Neutr0n requested a review from a team as a code owner February 9, 2026 18:38
@pytorch-bot
Copy link

pytorch-bot bot commented Feb 9, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/audio/4175

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Merge Blocking SEVs

There is 1 active merge blocking SEVs. Please view them below:

If you must merge, use @pytorchbot merge -f.

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla bot added the CLA Signed label Feb 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Loading failure errors should indicate what was being loaded when error occured

1 participant