Error log, retry notice, a waiting counter that keeps counting
CI / test (push) Successful in 1m8s
CI / build (push) Successful in 5m13s
CI / deploy (push) Skipped

- generation_errors: every failed attempt (model, attempt, outcome, duration); admin
  Hibanapló page and GET /v1/admin/errors; kept 90 days
- The waiting page counts from when the text was asked for (requested_at), not from
  the page load, so a reload no longer restarts it
- It says when an attempt failed and is retried, and when a failed text's unit was
  given back; admins see the error

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
feco
2026-11-18 21:47:37 +00:00
co-authored by Claude Opus 5.5
parent cf2fb9d454
commit 02e4e225f0
22 changed files with 569 additions and 25 deletions
+24 -1
View File
@@ -212,7 +212,8 @@ async fn cleanup_removes_only_expired_data(db: PgPool) {
("emails", 1),
("invites", 0),
("invitations", 0),
("prompt_previews", 0)
("prompt_previews", 0),
("generation_errors", 0)
]
);
let (left,): (Vec<Uuid>,) =
@@ -533,6 +534,18 @@ mod analyses {
let (status, attempts, ..) = row(&db, id).await;
assert_eq!((status.as_str(), attempts), ("failed", 3));
assert_eq!(refunds(&db, s.user).await, vec![1]);
// every failed attempt is in the admin error log
let log: Vec<(String, i32, String, String)> = sqlx::query_as(
"SELECT source, attempt, outcome, model FROM generation_errors WHERE item_id = $1 ORDER BY id",
)
.bind(id)
.fetch_all(&db)
.await
.unwrap();
let expected = |attempt: i32, outcome: &str| {
("analysis".to_string(), attempt, outcome.to_string(), "test/model".to_string())
};
assert_eq!(log, vec![expected(1, "retry"), expected(2, "retry"), expected(3, "failed")]);
}
#[sqlx::test(migrator = "db::MIGRATOR")]
@@ -780,6 +793,16 @@ mod analyses {
let models: Vec<String> =
fake.requests.lock().unwrap().iter().map(|b| b["model"].as_str().unwrap().to_string()).collect();
assert_eq!(models, ["cheap/model", "cheap/model", "test/model"]);
let outcomes: Vec<(String, String)> =
sqlx::query_as("SELECT outcome, model FROM generation_errors WHERE item_id = $1 ORDER BY id")
.bind(id)
.fetch_all(&db)
.await
.unwrap();
assert_eq!(
outcomes,
[("retry".to_string(), "cheap/model".to_string()), ("fallback".to_string(), "cheap/model".to_string())]
);
}
#[sqlx::test(migrator = "db::MIGRATOR")]