You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
UpdateEpisodeLink fails on every call: invalid CTE reference without RETURNING #320
FileRepository.UpdateEpisodeLink (internal/scanner/file_repo.go) runs a statement whose final SELECT COUNT(*) FROM inserted references a data-modifying CTE that has no RETURNING clause. PostgreSQL rejects this unconditionally with ERROR: WITH query "inserted" does not have a RETURNING clause (SQLSTATE 0A000), so every call fails at runtime, on every PostgreSQL version.
Introduced by #283 (Latest Episodes sort). Invisible because the only caller (internal/metadata/service.go, episode file linking) logs a warning and continues, and no CI runs database-backed Go tests.
Impact
The metadata-side single-file episode relink path has silently done nothing since #283: media_files.episode_id / season/episode numbers are not updated, the episode_libraries row is not inserted, and latest_episode_added_at is not bumped through this path. Bulk linking (BulkLinkEpisodesBySeries, which uses the correct CTE pattern) still works, which masked the breakage.
Reproduction
Run go test ./internal/scanner/ -run TestEpisodeLinkMaintainsLatestEpisodeAdded with SILO_TEST_DATABASE_URL pointing at a migrated scratch database — fails at episode_added_denorm_test.go:104 with the error above.
Fix
Make the INSERT … ON CONFLICT DO NOTHING the top-level statement of the WITH; the count was unused. Discovered while running the DB suites for #319.
Activity
fix(scanner): repair invalid CTE that made UpdateEpisodeLink fail on …
fix(scanner): repair invalid CTE that made UpdateEpisodeLink fail on …