fix(subs): retry a capped language next day
ci / web (push) Successful in 1m49s
e2e / e2e (push) Failing after 2m58s
ci / rust (push) Successful in 3m1s
ci / image (push) Successful in 3m47s

A `capped` row was excluded from the work list outright, and nothing
ever moved it back, so a language that hit a daily allowance was never
attempted again. §15 says budgets drain a backlog over days, which only
holds if the cap expires.

`pending` now returns a capped row once the UTC day it was capped in has
passed — the same boundary `subtitle_budget_spend.day` uses. The day
rule is in the query rather than the caller because `limit` is a window
over the whole list: a hundred newest files capped this morning would
otherwise hold every slot and hide the older gaps until tomorrow.

Capping no longer bumps `attempts`. That counter is the failure ladder,
and a budget that refused to spend never asked a provider.

Two reporting fixes alongside, both found chasing the same bug:

- The subtitle queue dropped `last_failure` on a capped row, so all four
  limits that write `capped` rendered identically. The sentence is the
  only thing that tells a provider budget from a 429.
- A translation engine with no API key reported itself as "not compiled
  into this binary", sending the operator to rebuild an image that was
  already correct.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Miguel Palhas
2026-09-20 18:43:08 +01:00
co-authored by Claude
parent dab3c06dd7
commit 70ba6ac376
7 changed files with 255 additions and 66 deletions
+5 -7
View File
@@ -692,7 +692,9 @@ fn reason_of(attempt: &arr_db::SubtitleAttempt) -> (String, Option<String>) {
("searching".to_owned(), None)
}
arr_db::SubtitleState::Unavailable => ("no_candidates".to_owned(), None),
arr_db::SubtitleState::Capped => ("capped".to_owned(), None),
// Two budgets and a provider 429 all write `capped`; the sentence is
// the only thing that says which.
arr_db::SubtitleState::Capped => ("capped".to_owned(), attempt.last_failure.clone()),
arr_db::SubtitleState::Failed => ("failed".to_owned(), attempt.last_failure.clone()),
}
}
@@ -1218,11 +1220,7 @@ pub async fn translate(
let engine = engine_name(&state, input.engine.as_deref()).await?;
let backend = state
.translation_backend(&engine)
.ok_or_else(|| {
ApiError::SubtitleUpstream(format!(
"translation engine '{engine}' is not compiled into this binary"
))
})?
.ok_or_else(|| ApiError::SubtitleUpstream(arr_subs::unusable_engine(&engine)))?
.clone();
let destination = target.sidecar(&target_language, true)?;
@@ -1487,7 +1485,7 @@ fn attempt_reason(
("searching".to_owned(), None)
}
arr_db::SubtitleState::Unavailable => ("no_candidates".to_owned(), None),
arr_db::SubtitleState::Capped => ("capped".to_owned(), None),
arr_db::SubtitleState::Capped => ("capped".to_owned(), last_failure),
arr_db::SubtitleState::Failed => ("failed".to_owned(), last_failure),
}
}