Prod 20-ago, 5 of 12 managed jobs failed and the alert said 'youtube download' — no download had terminally failed. Three fixes: - The quality probe now reports source duration, and /api/process rejects sources under MIN_SOURCE_SECONDS (default 45, 0 disables) on all three ingest paths with a clear message. A 24s YouTube Short cannot yield 15-60s clips; Gemini returns nothing and the job burns managed minutes to die with 'no usable clips' (3 of the 5 failures, one user retrying the same cat video). - _job_error_text drops per-attempt download warnings when a later attempt succeeded (HD-direct fails on every job since the server IP ban; static proxies recover it), and gained an 'Error:' marker so raised exceptions (RuntimeError:, GeminiBlockedError:) reach the alert instead of a bare 'Traceback ... exit code 1'. The classifier names 'no clips found (user video)' as its own content-shaped category. - (env, no code) DIRECT_FIRST=0 in prod: with the server IP banned the direct attempt only added ~10s and the noise behind these alerts.
80 lines
3.1 KiB
Python
80 lines
3.1 KiB
Python
"""Failure classification for the high-failure-rate alert."""
|
|
from cloud.alerts import _classify_failure
|
|
|
|
|
|
def test_no_audio():
|
|
assert _classify_failure("❌ NO_AUDIO: This video has no audio track.") == "no audio"
|
|
|
|
|
|
def test_youtube_bot_block():
|
|
assert _classify_failure("ERROR: [youtube] x: Sign in to confirm you're not a bot") == "youtube download"
|
|
assert _classify_failure("HTTP Error 403: Forbidden") == "youtube download"
|
|
assert _classify_failure("HTTP Error 429: Too Many Requests") == "youtube download"
|
|
|
|
|
|
def test_proxy():
|
|
assert _classify_failure("cannot connect to proxy") == "proxy"
|
|
assert _classify_failure("402 payment required") == "proxy"
|
|
|
|
|
|
def test_transcription():
|
|
assert _classify_failure("File faster_whisper/audio.py IndexError") == "transcription"
|
|
assert _classify_failure("av/container/streams.py tuple index out of range") == "transcription"
|
|
|
|
|
|
def test_gemini():
|
|
assert _classify_failure("google.genai error 500") == "gemini"
|
|
|
|
|
|
def test_ffmpeg():
|
|
assert _classify_failure("ffmpeg failed during reframe") == "ffmpeg/render"
|
|
|
|
|
|
def test_unknown_is_mixed():
|
|
assert _classify_failure("something weird happened") == "mixed"
|
|
|
|
|
|
def test_blocked_content_is_not_reported_as_outage():
|
|
assert _classify_failure(
|
|
"🚫 Gemini blocked this video's content (PROHIBITED_CONTENT)."
|
|
) == "blocked content (user video)"
|
|
|
|
|
|
def test_no_usable_clips_is_not_reported_as_outage():
|
|
assert _classify_failure(
|
|
"RuntimeError: Clip detection failed — Gemini did not return usable clips for this video."
|
|
) == "no clips found (user video)"
|
|
|
|
|
|
# --- _job_error_text: which log lines feed the classifier -----------------------
|
|
|
|
def test_recovered_download_attempts_do_not_mask_the_terminal_error():
|
|
"""HD-direct fails on every job (banned server IP) and a later attempt
|
|
succeeds; that per-attempt noise must not turn a Gemini failure into a
|
|
'youtube download' alert (prod 20-ago)."""
|
|
import pytest
|
|
app_module = pytest.importorskip("app")
|
|
logs = [
|
|
"📥 Download attempt: HD-direct",
|
|
"⚠️ Download attempt 'HD-direct' failed: ERROR: [youtube] x: Video unavailable.",
|
|
"📥 Download attempt: HD-static1",
|
|
"✅ Download succeeded (HD-static1).",
|
|
"Traceback (most recent call last):",
|
|
"RuntimeError: Clip detection failed — Gemini did not return usable clips for this video.",
|
|
]
|
|
err = app_module._job_error_text(logs)
|
|
assert "Video unavailable" not in err
|
|
assert _classify_failure(err) == "no clips found (user video)"
|
|
|
|
|
|
def test_terminal_download_failure_still_classifies_as_download():
|
|
import pytest
|
|
app_module = pytest.importorskip("app")
|
|
logs = [
|
|
"⚠️ Download attempt 'HD-direct' failed: ERROR: [youtube] x: Video unavailable.",
|
|
"❌ FATAL ERROR: YOUTUBE DOWNLOAD FAILED (all strategies)",
|
|
"Technical Details: ERROR: [youtube] x: Video unavailable. This content isn't available.",
|
|
"Process failed with exit code 1",
|
|
]
|
|
err = app_module._job_error_text(logs)
|
|
assert _classify_failure(err) == "youtube download"
|