Skip to content

Fix token expiry, Swagger CSRF, detector false positives, stuck pending files (2.10.9) - #92

Merged
ttlequals0 merged 5 commits into
mainfrom
fix/swagger-csrf-token-expiry
Nov 1, 2026
Merged

ttlequals0 merged 5 commits into
mainfrom
fix/swagger-csrf-token-expiry

Conversation

@ttlequals0

@ttlequals0 ttlequals0 commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner

2.10.6: token expiry 500 and Swagger CSRF

Creating an API token with an expiration returned HTTP 500, and every write request from the Swagger Try-it-out page failed with "The CSRF token is missing". Production logs show three TypeError: unsupported type for timedelta days component: str tracebacks on POST /api/tokens and the CSRF rejection on a POST with referer /api-docs.

What changed

  • POST /api/tokens coerces expires_in_days from the string the settings form sends and returns HTTP 400 for values that are not positive integers. A missing JSON body no longer raises.
  • The API docs page carries the CSRF token and Swagger UI sends it as X-CSRFToken on same-origin writes. Bearer requests are unaffected.
  • openapi.yaml documents expires_in_days with minimum: 1.
  • Version 2.10.6 with changelog entry.

Verification

  • python -m pytest tests/ -q: 877 passed, 56 skipped. The one error, test_scan_cancellation_race, needs PIXELPROBE_TEST_POSTGRES_URI and errors the same way on main.
  • python -m pytest tests/ -m postgres against a throwaway PostgreSQL 18 container: 54 passed, 1 skipped.
  • npm ci && npm run build, app import startup check against PostgreSQL, and docker compose config -q all pass.
  • New regression tests cover string, null, and invalid expiry values and the API docs CSRF wiring.

2.10.6 release

  • Image ttlequals0/pixelprobe:2.10.6 pushed after CI and CodeQL passed. Trivy: 0 HIGH, 0 CRITICAL, 556 MEDIUM (all Ubuntu 26.04 base packages, no fixes available, same as 2.10.5).
  • Deployed via Portainer; /api/version reports 2.10.6.
  • Production check: POST /api/tokens with "expires_in_days": "1" returns 201 with expires_at set, "abc" returns 400. The shipped docs bundle contains the X-CSRFToken interceptor.
  • latest is unchanged.

2.10.7: two detector false positives

Checked against the five files flagged in production:

File Verdict Evidence
Christopher Robin (2018) True positive 204 MB file, video and audio end at 123.5 s of 6236 s, ffmpeg reports "File ended prematurely"
Bunnylovr (2026) True positive 48 MiB of zero bytes at 810 MiB, 99.6 s gap in video packets at 842.5 s, 24 audio packets across that 100 s
Respect (2021) False positive Steady 23.976 fps packet cadence through the flagged 11.3 s (an in-memoriam end card). Header avg_frame_rate is 1000/1, so the detector expected 11303 packets and saw 273
30 Minutes or Less (2011) False positive First video sample is a 10-byte lone PPS; full decode produces only the lines from that sample, exit code 0
Good Luck Chuck (2007) False positive Same as above with an 11-byte PPS sample

Fixes:

  • Freeze corroboration takes the expected packet rate from the cadence measured around the window instead of the header's avg_frame_rate, which Matroska reports as 1000/1 when it cannot compute one. Against the real files, Respect no longer corroborates and Bunnylovr still reports missing content.
  • The container validation pass never decodes, so no frame! and missing picture in access unit can only come from stream probing. Up to NO_FRAME_PROBE_NOTICE_MAX (default 4) such lines are benign on a clean exit; more still mark the file corrupted. The real 30 Minutes file now passes that stage as healthy.
  • Regression tests cover both false positives and keep the true-positive paths (absent packets with a bogus header rate, a flood of no frame!, non-zero exit).

Full suite: 882 passed, 56 skipped, same PostgreSQL-environment error as before.

2.10.7 release

  • Image ttlequals0/pixelprobe:2.10.7 pushed after CI and CodeQL passed. Trivy: 0 HIGH, 0 CRITICAL, 556 MEDIUM, unchanged from 2.10.6.
  • Deployed via Portainer; /api/version reports 2.10.7.
  • latest is unchanged.

2.10.8: stuck pending files

17 inventory rows stayed pending after every force-scan-pending run. Their podcast folders had been deleted from the share, and two defects kept them stuck:

  • POST /api/force-scan-pending queued a run that logged "no files to scan" and finished with zero files. Since 2.9.3 chunk workers claim run members, and only directory discovery created them; a pending-type run skips discovery, so there was nothing to chunk. The run now seeds members from the pending inventory. A member whose file is gone is recorded as error with "File not found" and file_exists false, once its scan root passes the mount baseline and the nearest present directory under it still holds entries; an offline library leaves the row unchanged. A row with a completed observation keeps it and only loses its presence flag.
  • Orphan cleanup held those rows because the guard asked the folder directly above the vanished media folder, and that folder was gone too. It now walks up to the nearest directory still present, never above the scan root, and asks the library there. An unmounted library is still held, because nothing recorded answers from an empty mountpoint.

Tests: the orchestrator test reproduces the production result (COMPLETED, 0 files) before the fix; seeding, vanished-file claims, the deleted-subtree guard, and the unmounted-library hold are covered.

2.10.8 release

  • Image ttlequals0/pixelprobe:2.10.8 pushed after CI and CodeQL passed. Trivy: 0 HIGH, 0 CRITICAL, 556 MEDIUM, unchanged.
  • Deployed via Portainer; /api/version reports 2.10.8.
  • Production check: POST /api/force-scan-pending queued 17 files; pending count reached 0 within 10 seconds and the rows read error, "File not found", file_exists false.
  • latest is unchanged.

2.10.9: frame-count warnings on VFR DVD rips

41 of the 46 warning rows were Twilight Zone (1985) DVD rips flagged "Frame count differs from container metadata" by 7 to 15%. Two episodes checked in full: packets equal decoded frames, no decode errors, and the largest gap between consecutive frames is 0.067 s. The source is interlaced and was encoded with duplicate frames dropped, so the container's 29.97 fps overstates the frame count. Nothing is missing.

Stage 1 now probes the packet timeline when the decode confirms the deficit and decoded frames equal packets. If no gap exceeds 1 s and the missing tail accounts for at most a quarter of the deficit, the deficit is recorded as a variable frame rate note. A hole, a truncated tail, a decoder that loses packets, or a probe timeout keeps the warning. Against the real S03E25 file the result is the note and no warning.

The other five warnings hold up: Green Room has a 60 s Lionsgate anti-copy card mid-film, Portlandia S02E10 opens with 60 s of color bars and 89 s of silence, The Sound of Music and South Park S10E05 are genuine long holds (entr'acte card, static shot), and Beautiful Girls was replaced after its scan and clears on rescan.

2.10.9 release

  • Image ttlequals0/pixelprobe:2.10.9 pushed after CI and CodeQL passed. Trivy: 0 HIGH, 0 CRITICAL, 556 MEDIUM, unchanged.
  • Deployed via Portainer; /api/version reports 2.10.9.
  • Production check: forced rescans of Twilight Zone S03E25 and Beautiful Girls completed with no warnings.
  • latest is unchanged.

POST /api/tokens received expires_in_days as a string from the settings
form and raised TypeError in timedelta. The endpoint now coerces digit
strings and returns 400 for values that are not positive integers.

The API docs page had no CSRF token, so Swagger Try-it-out writes were
rejected. The page now carries the token and the request interceptor
sends X-CSRFToken on same-origin writes.
Freeze corroboration took the expected packet rate from the container's
avg_frame_rate, which Matroska reports as 1000/1 when it cannot compute
one, so a static end card with a steady 23.976 fps packet stream was
reported as 98% absent. The rate now comes from the cadence measured
around the window; the header value is only a fallback.

The -c copy validation pass never decodes, so a 'no frame!' line there
comes from stream probing. Blu-ray remuxes that start with a lone PPS
sample yield one such line on a clean file and were marked corrupted.
Up to NO_FRAME_PROBE_NOTICE_MAX of these are benign on a clean exit.
@ttlequals0 ttlequals0 changed the title Fix token expiry 500 and Swagger CSRF rejection (2.10.6) Fix token expiry 500, Swagger CSRF, and two detector false positives (2.10.7) Oct 31, 2026
Since 2.9.3 chunk workers claim run members and only discovery created
them, so a pending-type run had nothing to chunk and force-scan-pending
finalized every run with zero files. The orchestrator now seeds members
from the pending inventory. A member whose file is gone is recorded as
error with 'File not found' and file_exists false; a completed
observation keeps its status and only loses the presence flag.

Orphan cleanup asked the folder directly above a vanished media folder,
which is gone too when a whole podcast or show is removed, so those rows
were held as a possible outage. The guard now walks up to the nearest
present directory and asks the library there.
@ttlequals0 ttlequals0 changed the title Fix token expiry 500, Swagger CSRF, and two detector false positives (2.10.7) Fix token expiry, Swagger CSRF, detector false positives, stuck pending files (2.10.8) Nov 1, 2026
A deleted file and an offline mount read the same. The claim path now
writes the missing state only when the containing scan root passes its
mount baseline and the nearest present directory under it holds entries;
otherwise the member is unavailable and the inventory row keeps its state.
The cleanup guard's ancestor walk stops at the scan root so evidence
always comes from the same library.
Interlaced DVD rips encoded with duplicate frames dropped carry a
container rate of 29.97 fps while frames arrive at a mix of 33 ms and
67 ms steps, so Stage 1 warned that 7 to 15 percent of frames were
missing on files where every packet decodes and nothing is absent.

When the decode confirms the deficit and decoded frames equal packets,
Stage 1 now probes the packet timeline. No gap over one second and a
missing tail that explains at most a quarter of the deficit means a
variable frame rate note. A hole, a truncated tail, a decoder that
loses packets, or a probe timeout still warns.
@ttlequals0 ttlequals0 changed the title Fix token expiry, Swagger CSRF, detector false positives, stuck pending files (2.10.8) Fix token expiry, Swagger CSRF, detector false positives, stuck pending files (2.10.9) Nov 1, 2026
@ttlequals0
ttlequals0 merged commit 7832243 into main Nov 1, 2026
8 checks passed
@ttlequals0
ttlequals0 deleted the fix/swagger-csrf-token-expiry branch November 1, 2026 03:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant