Skip to content

List only the candidate frames that reached the disk - #216

Merged
nmbrthirteen merged 2 commits into
mainfrom
fix/thumbnail-frame-writes
Sep 6, 2026
Merged

List only the candidate frames that reached the disk#216
nmbrthirteen merged 2 commits into
mainfrom
fix/thumbnail-frame-writes

Conversation

@nmbrthirteen

@nmbrthirteen nmbrthirteen commented Sep 6, 2026

Copy link
Copy Markdown
Owner

Two faults in extract_candidate_frames, both of which end with a clip having no picture.

A frame that was never written was reported anyway. cv2.imwrite answers a failed write by returning False rather than raising, and on a render box a full disk is the usual reason. The path went into the returned list regardless, so the cloud worker's upload of that frame failed on the stat and thumbnail-render refused it with no frame at ... — the guard from #214 reporting a problem made here. Now the frame is skipped and logged.

The top-up pass crashed on numpy. When strict diversity leaves fewer candidates than were asked for, a second pass fills the list and skipped what was already chosen with if c in selected. A candidate is a dict carrying its own numpy frame, so in compared those element-wise and raised the truth value of an array with more than one element is ambiguous, taking the command down and leaving the caller with nothing rather than the two or three frames already picked. Identity is what the check meant.

Reported from production: thumbnail render failed: no frame at /var/lib/podcli-work/.../thumbs-.../frames/frame_2.jpg.

The matching guard on the cloud side (ignore a listed frame that is not on disk) is on podcli-cloud main as a262be5.

Summary by CodeRabbit

  • Bug Fixes
    • Improved video frame selection to avoid errors when comparing candidate frames.
    • Failed frame saves are now detected and skipped instead of producing invalid file references.
    • Added warnings when a frame cannot be saved, improving visibility into storage-related issues.

When strict diversity leaves fewer candidates than were asked for, a second
pass tops the list up and skips anything already chosen with `if c in
selected`. A candidate is a dict carrying its own numpy frame, and `in`
compares those element-wise, so the check raised "the truth value of an array
with more than one element is ambiguous" and took the whole command down with
it. Every caller then saw no frames at all rather than the two or three that
had already been picked, and the clip got no picture.

Identity is what the check meant: the same candidate, not an equal one.
cv2.imwrite answers a failed write by returning False rather than raising, and
on a render box a full disk is the usual reason. The frame went into the
returned list regardless, so thumbnail-options handed its caller a path to a
file that is not there: the cloud worker's upload of it failed on the stat,
and thumbnail-render refused it with "no frame at ...", which is the guard
added with the last thumbnail fixes reporting a problem made here.

Skip a frame that did not get written, and log which one it was.
@coderabbitai

coderabbitai Bot commented Sep 6, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: f64380c1-d137-40b1-844e-d721f55cd799

📥 Commits

Reviewing files that changed from the base of the PR and between bb2ab27 and c55370c.

📒 Files selected for processing (1)
  • backend/services/thumbnail_ai.py

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The thumbnail pipeline now compares candidate frames by identity during relaxed diversity selection. It also checks image write results, logs failures, and skips frames that were not saved.

Changes

Thumbnail pipeline

Layer / File(s) Summary
Candidate frame identity handling
backend/services/thumbnail_ai.py
The relaxed time-only diversity pass uses identity comparison for candidate dictionaries containing NumPy frames.
Failed frame write handling
backend/services/thumbnail_ai.py
The frame-saving path checks cv2.imwrite. Failed writes trigger a warning through log_event and exclude the frame from the returned results.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to c5537

Thumbnail extraction now retains valid candidate selection behavior and avoids returning paths for frames that were not written, preventing downstream rendering from receiving missing files. No current merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the change that only successfully written candidate frames are included. It does not mention the separate candidate identity comparison fix, but a title does not need to…
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/thumbnail-frame-writes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nmbrthirteen
nmbrthirteen merged commit 79ae377 into main Sep 6, 2026
14 checks passed
@nmbrthirteen nmbrthirteen mentioned this pull request Sep 6, 2026
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