Skip to content

Commit 96f64cd

Browse files
MrDesjardinsclaude
andcommitted
Fix path expansion in weekly summary audio streaming
FileResponse was receiving unexpanded path with ~ which caused FileNotFoundError even though the file exists. Now using expand_path() before passing to FileResponse. Fixes: RuntimeError: File at path ~/.cache/audio-stream-server/weekly-summaries/2026-W07.mp3 does not exist Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 6910019 commit 96f64cd

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

routes/weekly_summaries.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,21 @@ async def stream_summary_audio(week_year: str):
6262
status_code=404, detail=f"No audio file for summary: {week_year}"
6363
)
6464

65+
# Expand path (handles ~ and symlinks)
66+
expanded_path = expand_path(audio_path)
67+
6568
# Check if file exists
66-
if not expand_path(audio_path).exists():
67-
logger.error(f"Audio file not found: {audio_path}")
69+
if not expanded_path.exists():
70+
logger.error(
71+
f"Audio file not found: {audio_path} (expanded: {expanded_path})"
72+
)
6873
raise HTTPException(
6974
status_code=404, detail=f"Audio file not found: {audio_path}"
7075
)
7176

72-
# Stream the file
77+
# Stream the file (must use expanded path)
7378
return FileResponse(
74-
audio_path,
79+
expanded_path,
7580
media_type="audio/mpeg",
7681
filename=f"{week_year}.mp3",
7782
)

0 commit comments

Comments
 (0)