The deep review of the branch raised 47 findings, 18 of which survived adversarial verification. Grouped by what they actually were: **The size ceiling inverted at its boundary.** `remaining_bytes` clamped to 0 for a user already at their storage cap, and `build_ydl_opts` reads 0 as "no limit" — so the one user over quota was the only one downloading with no ceiling at all. `check_enqueue` could not catch it: it ran while the job was queued and the user was still under the cap. The arithmetic moves into `quota.remaining_bytes` (where every other max_bytes decision lives, and where it can be tested), and the worker now fails the job outright rather than proceeding unbounded — as a non-retryable `quota_exceeded`, since retrying cannot help until space is freed. **Silent failures in the new account panel.** All three actions went through `quiet: true` endpoints, which suppress the global error dialog on the promise that the caller reports inline — with no `onError`, that promise was broken and a refusal rendered as nothing. On the broken-SMTP instance this panel exists for, an admin would read silence as "the mail went out". The co-invalidation set and the email-off predicate move to `lib/adminUsers`, shared with the pending-access queue, so the two copies of these mutations cannot drift apart again — which is how half of this was lost in the first place. **A rollback recipe that destroyed data without working.** `alembic downgrade -1` steps back one migration, but a release routinely ships several (0.80.0 shipped four): it drops the newest one's columns and leaves the schema at a revision the older image also cannot resolve, i.e. the crash loop it was meant to escape, minus the data. The dump restore is now the recommended path, and the alembic route asks the target version for its own head revision instead of counting backwards. Also: redirects named in the urlguard docstring beside the DNS-rebinding residual they share a fix with (SEC-17); a malformed port refused as `bad_port` instead of escaping as a 500; the pull cooldown extended to the sibling route spending the same QuotaAction; restore stops the app before dropping its tables; the PowerShell cleanup can no longer decide the script's verdict on 5.1, nor report the wrong exit code; the documented one-liners hardened to match the scripts; the registry's retention window stated where pinning is advertised; the two banners made mutually exclusive so neither can shadow the other; `hover:bg-hover` (a utility this project never generated) replaced by the `selectable` recipe; the clipboard helper reused; and the sync cooldown's copy swept to the two callers that discarded it. Verified: gate green (vitest 678, pytest 949), and the panel, the row hover and the reset banner UAT'd on localdev.
77 lines
4.6 KiB
Python
77 lines
4.6 KiB
Python
"""Category classification of raw yt-dlp / ffmpeg download-failure strings (S2)."""
|
|
|
|
from app.downloads import errors as dlerrors
|
|
from app.downloads.errors import classify
|
|
|
|
|
|
def test_real_ytdlp_messages_map_to_categories():
|
|
# Verbatim-shaped yt-dlp / ffmpeg output → the category the UI explains.
|
|
cases = {
|
|
"ERROR: [youtube] xxxxxxxxxxx: Video unavailable": "unavailable",
|
|
"ERROR: [youtube] abc: Private video. Sign in if you've been granted access": "unavailable",
|
|
"ERROR: [youtube] abc: This video is no longer available because the uploader has closed their "
|
|
"account": "unavailable",
|
|
"ERROR: [youtube] abc: Sign in to confirm your age. This video may be inappropriate": "login_required",
|
|
"ERROR: [youtube] abc: Sign in to confirm you're not a bot": "login_required",
|
|
"ERROR: [youtube] abc: Join this channel to get access to members-only content": "login_required",
|
|
"ERROR: [Reddit] 1vi1x56: Account authentication is required.": "login_required",
|
|
# Closed-group / private-post auth walls: yt-dlp either says to sign in or suggests cookies.
|
|
"ERROR: [facebook] 123: You must be logged in to see this post": "login_required",
|
|
"ERROR: [facebook] 123: Login required. Use --cookies for the authentication.": "login_required",
|
|
"ERROR: [instagram] abc: This content is only available for registered users": "login_required",
|
|
"ERROR: [youtube] abc: Sign in to confirm... Use --cookies-from-browser or --cookies": "login_required",
|
|
# A site yt-dlp has no extractor for at all — distinct from an auth wall, still non-retryable.
|
|
"ERROR: Unsupported URL: https://example.com/whatever": "unsupported_host",
|
|
"ERROR: [youtube] abc: The uploader has not made this video available in your country": "geo_blocked",
|
|
"ERROR: [youtube] abc: Requested format is not available": "format_unavailable",
|
|
"ERROR: [youtube] abc: Only images are available for download": "format_unavailable",
|
|
"ERROR: [generic] This video is DRM protected": "drm",
|
|
"ffmpeg failed (1): Conversion failed!": "postprocess",
|
|
"The source download is no longer available.": "source_missing",
|
|
"The source file is missing.": "source_missing",
|
|
"ERROR: unable to download video data: HTTP Error 403: Forbidden": "network",
|
|
"ERROR: Unable to download webpage: <urlopen error timed out>": "network",
|
|
}
|
|
for msg, expected in cases.items():
|
|
assert classify(msg) == expected, f"{msg!r} → {classify(msg)!r}, expected {expected!r}"
|
|
|
|
|
|
def test_unmatched_and_empty_are_unknown():
|
|
assert classify("some totally novel failure text") == "unknown"
|
|
assert classify("") == "unknown"
|
|
assert classify(None) == "unknown"
|
|
|
|
|
|
def test_matching_is_case_insensitive():
|
|
assert classify("VIDEO UNAVAILABLE") == "unavailable"
|
|
assert classify("drm protected") == "drm"
|
|
|
|
|
|
def test_login_beats_generic_unavailable_when_both_present():
|
|
# A members-only video also reads as "unavailable" to a signed-out client; the sign-in cause is
|
|
# the more useful, more specific one, so it must win (rule order guards this).
|
|
msg = (
|
|
"ERROR: [youtube] abc: Join this channel to get access to members-only content. "
|
|
"This video is unavailable"
|
|
)
|
|
assert classify(msg) == "login_required"
|
|
|
|
|
|
def test_our_own_worker_refusals_classify_as_themselves():
|
|
# The worker raises these itself (not yt-dlp), and the rule that catches each one matches only a
|
|
# fragment of the text. Pinning message and rule together is what stops an edit to the wording
|
|
# from silently orphaning the category — the UI would then fall back to "Download failed".
|
|
assert classify(dlerrors.QUOTA_FULL_MESSAGE) == "quota_exceeded"
|
|
|
|
|
|
def test_a_url_jobs_network_failure_is_redacted_but_youtube_keeps_its_text():
|
|
# SEC-12: the raw transport text for a user-chosen host:port is a port-scanner readout, so it is
|
|
# replaced for `url` jobs. Everything else must survive verbatim, or a real diagnosis is lost.
|
|
raw = "ERROR: Unable to download webpage: <urlopen error [Errno 111] Connection refused>"
|
|
assert dlerrors.user_error_text("url", raw, "network") == dlerrors.NETWORK_REDACTED_MESSAGE
|
|
# Same failure, but the destination was never user-chosen — nothing to leak, keep the detail.
|
|
assert dlerrors.user_error_text("youtube", raw, "network") == raw
|
|
# A user-chosen host, but a category that says something real about the CONTENT, not the network.
|
|
login = "ERROR: [facebook] 123: You must be logged in to see this post"
|
|
assert dlerrors.user_error_text("url", login, "login_required") == login
|