lfnovo/open-notebook · error · HTTPException

Failed to delete episode

Error message

Failed to delete episode

What it means

Generic 500 from the delete-podcast-episode endpoint when an unexpected exception occurs while deleting an episode. The true cause is only in the server log ('Error deleting podcast episode: ...').

Source

Thrown at api/routers/podcasts.py:430

        # Get the episode first to check if it exists and get the audio file path
        episode = await PodcastService.get_episode(episode_id)

        # Delete the physical audio file if it exists
        _delete_episode_audio(episode, episode_id)

        # Delete the episode from the database
        await episode.delete()

        logger.info(f"Deleted podcast episode: {episode_id}")
        return {"message": "Episode deleted successfully", "episode_id": episode_id}

    except HTTPException:
        raise
    except OpenNotebookError:
        raise
    except Exception as e:
        logger.error(f"Error deleting podcast episode: {str(e)}")
        raise HTTPException(
            status_code=500, detail="Failed to delete episode"
        )

View on GitHub (pinned to a7de90d38a)

Solutions

  1. Check server logs for the underlying exception string
  2. Verify the episode_id exists via GET before deleting
  3. Ensure SurrealDB is running and migrations completed on API startup
  4. Remove dependent records (notes, jobs) or rely on cascade if implemented
Defensive patterns

Strategy: try-catch

Validate before calling

const res = await fetch(`/api/podcasts/episodes/${id}`);
if (res.status === 404) { /* nothing to delete */ }

Try / catch

try {
  await api.delete(`/podcasts/episodes/${id}`);
} catch (e) {
  if (e.status === 500) refreshListAndCheckServerLogs();
}

Prevention

When it happens

Trigger: DELETE /api/podcasts/episodes/{episode_id} when the delete touches missing records, fails a DB transaction, or the episode has orphaned related rows that break deletion logic.

Common situations: Deleting an already-deleted episode concurrently, SurrealDB down or schema drift after migration, foreign references (notes, jobs) pointing at the episode.

Related errors


AI-assisted analysis of lfnovo/open-notebook@a7de90d38a (2026-08-27). Data as JSON: /api/errors/5356386a77e22892. Report an issue: GitHub.