Severity: minor (robustness; not reachable via current writes)
Where
iOS/Pollux/DatabaseManager.swift, episode(from:):
durationSecs: (row["duration_secs"] as Int64?).map { UInt32($0) }
and the same pattern for playback_position_secs.
Problem
UInt32(_:) traps on any value above UInt32.max. The schema CHECK constraints
enforce >= 0 but set no upper bound, so a row written by a later schema version,
external tooling, or a manual DB edit crashes the app on read — and episode(from:)
runs for every row on library load. The write path already degrades gracefully
(fileSizeBytes uses Int64(exactly:) → NULL on overflow), so read and write
currently disagree about whether bad data is survivable. There's a code comment
documenting this today.
Suggested fix
Use UInt32(exactly:) and treat overflow as nil (both fields are already
Optional), matching the write path's non-trapping behavior.
Severity: minor (robustness; not reachable via current writes)
Where
iOS/Pollux/DatabaseManager.swift,episode(from:):durationSecs: (row["duration_secs"] as Int64?).map { UInt32($0) }and the same pattern for
playback_position_secs.Problem
UInt32(_:)traps on any value aboveUInt32.max. The schema CHECK constraintsenforce
>= 0but set no upper bound, so a row written by a later schema version,external tooling, or a manual DB edit crashes the app on read — and
episode(from:)runs for every row on library load. The write path already degrades gracefully
(
fileSizeBytesusesInt64(exactly:)→ NULL on overflow), so read and writecurrently disagree about whether bad data is survivable. There's a code comment
documenting this today.
Suggested fix
Use
UInt32(exactly:)and treat overflow asnil(both fields are alreadyOptional), matching the write path's non-trapping behavior.