Error log, retry notice, a waiting counter that keeps counting
- 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:
@@ -1695,3 +1695,44 @@ async fn admins_restart_open_generations_with_the_current_models(pool: PgPool) {
|
||||
sqlx::query("UPDATE analyses SET status = 'done', content = '{}'").execute(&pool).await.unwrap();
|
||||
assert_eq!(app.post("/v1/admin/jobs/restart", Some(&admin), json!({})).await.body["restarted"], 0);
|
||||
}
|
||||
|
||||
#[sqlx::test(migrator = "db::MIGRATOR")]
|
||||
async fn admins_read_the_error_log(pool: PgPool) {
|
||||
let app = TestApp::new(pool.clone()).await;
|
||||
let admin = app.register("admin@example.com", "Admin").await;
|
||||
let anna = app.register("anna@example.com", "Anna").await;
|
||||
let chart = app.chart(&anna, "Saját", true, "1990-03-15").await;
|
||||
let chart_id = chart["id"].as_str().unwrap();
|
||||
let analysis: uuid::Uuid = sqlx::query_scalar("SELECT id FROM analyses WHERE chart_id = $1::uuid")
|
||||
.bind(chart_id)
|
||||
.fetch_one(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
for (attempt, outcome) in [(1, "retry"), (2, "failed")] {
|
||||
sqlx::query(
|
||||
"INSERT INTO generation_errors (source, item_id, kind, model, attempt, outcome, error, seconds) \
|
||||
VALUES ('analysis', $1, 'summary', 'cheap/model', $2, $3, 'answer cut off at the token limit', 301)",
|
||||
)
|
||||
.bind(analysis)
|
||||
.bind(attempt)
|
||||
.bind(outcome)
|
||||
.execute(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
assert_eq!(app.get("/v1/admin/errors", Some(&anna)).await.status, StatusCode::FORBIDDEN);
|
||||
let r = app.get("/v1/admin/errors", Some(&admin)).await;
|
||||
assert_eq!((r.status, &r.body["total"], &r.body["last_day"]), (StatusCode::OK, &json!(2), &json!(2)), "{}", r.body);
|
||||
let first = &r.body["errors"][0];
|
||||
assert_eq!(
|
||||
(&first["outcome"], &first["attempt"], &first["user"], &first["seconds"]),
|
||||
(&json!("failed"), &json!(2), &json!("anna@example.com"), &json!(301))
|
||||
);
|
||||
let r = app.get("/v1/admin/errors?outcome=retry", Some(&admin)).await;
|
||||
assert_eq!(r.body["errors"].as_array().unwrap().len(), 1);
|
||||
assert_eq!(app.get("/v1/admin/errors?source=question", Some(&admin)).await.body["total"], 0);
|
||||
// users see the attempts of their analysis (the page says it is tried again)
|
||||
let r = app.get(&format!("/v1/analyses/{analysis}"), Some(&anna)).await;
|
||||
assert_eq!(r.body["attempts"], 0);
|
||||
assert!(r.body["next_attempt_at"].is_string());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user