Skip to content

fix: catch MutagenError on corrupt audio files#11

Merged
GeiserX merged 1 commit into
mainfrom
fix/mutagen-error-handling
May 13, 2026
Merged

fix: catch MutagenError on corrupt audio files#11
GeiserX merged 1 commit into
mainfrom
fix/mutagen-error-handling

Conversation

@GeiserX
Copy link
Copy Markdown
Owner

@GeiserX GeiserX commented May 13, 2026

Summary

  • Wraps mutagen.File() calls in try/except for MutagenError, skipping files with corrupt or malformed metadata instead of crashing
  • Fixes MP4 files with truncated chapter atoms causing MP4MetadataError during directory scan

Test plan

  • All 41 existing tests pass
  • Files with corrupt metadata are silently skipped, scan continues

Closes #10

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Improved error handling when reading audio metadata. The application now gracefully skips files with metadata read errors instead of interrupting the search process, ensuring more reliable file scanning operations.

Review Change Stack

Files with malformed metadata (e.g. MP4 with truncated chapter atoms)
crash the scan. Catch MutagenError and skip unreadable files gracefully.

Closes #10
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 13, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0a506f4d-7ade-478b-9e66-336b142d668a

📥 Commits

Reviewing files that changed from the base of the PR and between ac919d4 and 9f52899.

📒 Files selected for processing (1)
  • src/slskd_transform/search.py

📝 Walkthrough

Walkthrough

The list_files_with_duration function in search.py now gracefully handles audio files with corrupted or malformed metadata by wrapping mutagen calls in try/except blocks. Files that raise mutagen.MutagenError are skipped during directory traversal rather than terminating execution.

Changes

Audio metadata resilience

Layer / File(s) Summary
Error handling for mutagen metadata reads
src/slskd_transform/search.py
Both the recursive and non-recursive scan branches wrap mutagen.File(..., easy=True) in try/except blocks targeting mutagen.MutagenError, allowing the function to skip corrupted audio files and continue processing.

🎯 1 (Trivial) | ⏱️ ~3 minutes

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/mutagen-error-handling

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@GeiserX GeiserX merged commit 653376b into main May 13, 2026
1 of 2 checks passed
@GeiserX GeiserX deleted the fix/mutagen-error-handling branch May 13, 2026 11:32
@codecov
Copy link
Copy Markdown

codecov Bot commented May 13, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.09%. Comparing base (ac919d4) to head (9f52899).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/slskd_transform/search.py 50.00% 4 Missing ⚠️

❌ Your patch status has failed because the patch coverage (50.00%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage.
❌ Your project status has failed because the head coverage (85.09%) is below the target coverage (90.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #11      +/-   ##
==========================================
- Coverage   86.24%   85.09%   -1.16%     
==========================================
  Files           6        6              
  Lines         269      275       +6     
==========================================
+ Hits          232      234       +2     
- Misses         37       41       +4     
Files with missing lines Coverage Δ
src/slskd_transform/search.py 81.13% <50.00%> (-2.87%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Running slksd-transform search -r results in error. mutagen.mp4.mp4metadataerror

1 participant