Summary
The /api/v1/items/reindex endpoint successfully fetches new episodes from TVDB and merges them into the session, but never calls session.commit(). The session rolls back on close, so new seasons/episodes are silently lost. The endpoint returns "Successfully re-indexed" even though nothing was persisted.
Steps to Reproduce
- Have a show with new episodes available on TVDB that aren't in the Riven database yet
- Call
POST /api/v1/items/reindex with the show's item_id
- API returns
{"message": "Successfully re-indexed <show>"}
- Check the database — no new episodes were added
Root Cause
In src/routers/secure/items.py, the reindex endpoint calls apply_item_mutation() but never follows it with session.commit(). Every other caller of apply_item_mutation in the same file does call session.commit() immediately after. The function's own docstring states: "Caller is responsible for session.commit()."
The scheduler's _run_reindex_for_item performs the same operation and does commit — so the scheduler path works correctly. Only the API endpoint is affected.
Relevant Code
src/routers/secure/items.py — the reindex handler (around line 1356):
apply_item_mutation(
program=di[Program],
session=session,
item=item,
mutation_fn=mutation,
bubble_parents=True,
)
# <-- session.commit() missing here
logger.info(f"Successfully re-indexed {item.log_string}")
Compare with every other apply_item_mutation caller in the same file, which all have session.commit() after.
Fix
Add session.commit() between apply_item_mutation(...) and the logger.info(...) line, matching the pattern used by all other callers.
Environment
- Riven v1.0.0 (
spoked/riven:dev, image built 2026-04-11)
- PostgreSQL 17 Alpine
Summary
The
/api/v1/items/reindexendpoint successfully fetches new episodes from TVDB and merges them into the session, but never callssession.commit(). The session rolls back on close, so new seasons/episodes are silently lost. The endpoint returns "Successfully re-indexed" even though nothing was persisted.Steps to Reproduce
POST /api/v1/items/reindexwith the show's item_id{"message": "Successfully re-indexed <show>"}Root Cause
In
src/routers/secure/items.py, the reindex endpoint callsapply_item_mutation()but never follows it withsession.commit(). Every other caller ofapply_item_mutationin the same file does callsession.commit()immediately after. The function's own docstring states: "Caller is responsible for session.commit()."The scheduler's
_run_reindex_for_itemperforms the same operation and does commit — so the scheduler path works correctly. Only the API endpoint is affected.Relevant Code
src/routers/secure/items.py— the reindex handler (around line 1356):Compare with every other
apply_item_mutationcaller in the same file, which all havesession.commit()after.Fix
Add
session.commit()betweenapply_item_mutation(...)and thelogger.info(...)line, matching the pattern used by all other callers.Environment
spoked/riven:dev, image built 2026-04-11)