Resolved

Python upload watcher incorrectly archives failed YouTube uploads

YouTube API
Upload Automation
Error Handling
Retry Logic
Debugging

The upload watcher system was archiving failed videos after maximum retries, even for transient errors, leading to silent data loss and incorrect success states.

A Python-based upload watcher system managed YouTube video uploads, including retry logic and archiving for both horizontal and vertical (Shorts) videos. However, it incorrectly archived videos that failed due to transient errors, causing silent data loss and misleading success states.

Issue

The upload watcher incorrectly archived videos after maximum retries, even for transient errors like SERVER_ERROR. This resulted in:

  • Silent data loss: Videos disappeared from upload queues without reaching YouTube.
  • False success states: Archived files appeared to be successfully uploaded when they actually failed.
  • Missing content: Series parts were absent from YouTube despite being present in the archive.

Culprit

The issue stemmed from contradictory error handling where transient errors were incorrectly classified as permanent failures:

  • Error classification mismatch: Errors like SERVER_ERROR and AUTH_ERROR were marked as retriable but archived after three retries.
  • Incorrect archive logic: Non-quota errors triggered archive calls instead of continued retries.
  • Misaligned comments: Code comments incorrectly implied permanent failures for transient errors.

Solution

Retry Strategy Changes

  • Transient errors (SERVER_ERROR, AUTH_ERROR): Implemented infinite retries with delayed re-queueing (12-hour delays) instead of archiving.
  • Permanent errors: Re-queued with a 24-hour delay instead of immediate archiving.

Archive Policy

  • Only successful uploads trigger archiving, ensuring that failed videos are not prematurely archived.

Result: The system now correctly handles transient errors by retrying indefinitely, preventing data loss and ensuring proper error states are maintained.