114 exception handlers neither logged nor re-raised. The defect was never that
they are silent — plenty of them should be — it is that their silence said
nothing, so nobody could tell a decision from an oversight. Each one has now been
read. 44 got a line; the other 70 carry `# silent-ok: <why>`.
What the silent ones had been hiding, in the cases that got a line:
- A failed ffprobe sent every HDR file down the 8-bit pipeline, so playback
degraded to a software transcode with nothing saying why; a failed audio probe
collapsed a multi-audio file to one track and the player showed no language
picker; a failed first-PTS probe left subtitles seconds out of sync.
- A subtitle sidecar that existed but would not parse made a PARTIAL track read as
complete, permanently — the viewer loses every cue past the cached window.
- An unreadable crop/trim/cut-list in an edit spec was dropped, so the clip came
out uncropped, untrimmed, or shorter than the one the user built.
- A dropped `max_height` downloaded at best quality against an explicit cap.
- A failed videos.list enrich made every candidate undroppable-from-judgement and
therefore dropped: a working search rendered as "no results".
- An unusable password hash answered as "wrong password", locking the owner out
and telling them they mistyped; a rotated TOKEN_ENCRYPTION_KEY turned every
stored token into "not connected".
- A stored admin setting that would not coerce fell back to the env default while
the settings page went on showing the saved value.
- A one-off InnerTube config failure pinned the whole process to the hard-coded
fallback key, and searches return nothing when that goes stale.
- The HLS sweep reported 0 swept — like a clean run — when it could not list its
own root, leaving every crashed session's segments on disk forever.
Four of them are counted rather than logged per item (dropped cues, dropped cut
list segments, unreclaimed GC files) and reported once per call, because the
alternative is one line per cue over a whole subtitle track.
ruff gains S110 and BLE001. Every blind `except Exception` that remains carries
`# noqa: BLE001 — <why>`, which is the point: catching everything is sometimes
right, and always worth a sentence. plex/sync.py's three best-effort backfill
catches now keep the traceback — a blind catch over a batch that fetches AND
writes could be Plex, the database or our own bug, and `%s` of the exception told
them apart badly. main.py's boot-time log-level read likewise.
logs.event's `code` is positional-only now: `event("x", code=...)` was a TypeError,
and `code` is exactly the word a caller reaches for when the thing that failed has
one of its own.
tests/test_swallowed_exceptions.py is the wider rule ruff cannot see: a handler
that neither logs nor re-raises must say why. Both cases mutation-checked — a
marker removed and a log line removed each fail it, naming the handler.
30 lines
2.1 KiB
TOML
30 lines
2.1 KiB
TOML
# Ruff config for the Siftlode backend. Keeps ruff's default rule set (E4/E7/E9 + F = the
|
|
# high-signal pyflakes/pycodestyle checks that catch real dead code + bugs), but ignores E402:
|
|
# a handful of modules (e.g. main.py) deliberately run setup — logging config, sys.path — before
|
|
# importing route modules, so "module import not at top of file" is intentional there, not cruft.
|
|
#
|
|
# line-length 100 (ruff's default is 88): matches the frontend prettier printWidth so both halves of
|
|
# the repo wrap at the same width, and it's the width `ruff format` enforces (gated via
|
|
# `ruff format --check` alongside `ruff check`).
|
|
line-length = 100
|
|
|
|
[lint]
|
|
# Beyond the default set, the rules that hold a LOG LINE to what E22.5 makes of it:
|
|
# LOG — stdlib logging misuse (`.warn()`, a logger built by hand, `exc_info` on `.exception`)
|
|
# G — the call's shape: %-style args, never an f-string the level filter cannot skip, and
|
|
# never `str(exc)` where `exc_info` would carry the traceback
|
|
# T20 — `print` instead of a log line. Two deliberate ones remain, each with its `# noqa`
|
|
# and a why: `downloads/runner.py` prints before logging is configured, and
|
|
# `logsink.py` reports the SINK's own failure, which cannot be logged into the sink.
|
|
# TRY400 — `.error()` in an `except` where `.exception()` would keep the traceback
|
|
# TRY401 — the exception spelled into the message AND passed as `exc_info` (it is in both)
|
|
# S112 — `except: continue`, the silent swallow inside a loop
|
|
# S110 — `except: pass`, the same thing outside one
|
|
# BLE001 — a blind `except Exception`. Every one that remains carries `# noqa: BLE001 — <why>`,
|
|
# which is the point: catching everything is sometimes right (a worker thread with
|
|
# nobody to raise to, a best-effort backfill inside a sync) and always worth a sentence.
|
|
# The wider rule these two enforce lives in tests/test_swallowed_exceptions.py: a handler that
|
|
# neither logs nor re-raises says `# silent-ok: <why>`. Ruff sees only the two narrow shapes.
|
|
extend-select = ["LOG", "G", "T20", "TRY400", "TRY401", "S110", "S112", "BLE001"]
|
|
ignore = ["E402"]
|