From 062efa6583b7fea292a4f485659661d266461611 Mon Sep 17 00:00:00 2001 From: aur-build Date: Wed, 18 Nov 2026 15:48:02 +0000 Subject: review: a database failure is never reported to a reviewer as a stale review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `approve()` returned `Result` and then collapsed every inner failure into `Stale::NotPending { state: e.to_string() }`, so a SQLite error reached the human as "review is no longer pending (state: sqlite: …)". That is the one message that tells a reviewer to look again when the truth is that the write failed — and the transaction had already rolled back, so their review was still pending and nothing on screen explained why. `bulk()` bent the same variant to mean "high risk", "unknown decision" and "the database failed", and handed back a fabricated `Approval { id: 0 }` for a rejection that recorded no approval at all. `approve()` now returns `Result` with two families: `Stale(Stale)` — what is stored is not what was displayed, look again — and `System(Error)` — the write failed, nothing about the review is at fault. The UI answers the first with the 409 and fresh diff it already gave, and the second with a 500 that names the cause; the CLI exits 2 for the first and propagates the second as an error. `bulk()` got its own vocabulary — `BulkOutcome::{Approved, Rejected, Refused(BulkRefusal)}` with `HighRiskUnconfirmed`, `UnknownDecision`, `NotFound`, `Stale` and `System` — and returns no approval row for a rejection, because there is none. The invented `id: 0` is gone. The web handler had its own copy of the bulk loop; it now calls `approve::bulk`, so the page and the library cannot disagree about what §7.4 says. Three tests: a dropped `audit` table mid-transaction must surface as `System` and must leave the review pending and the approval table empty; bulk refusals must name the risk, the unknown decision, and (after a real approval) the genuine staleness as three different things; a bulk rejection must record a `rejected` row and hand back nothing. --- src/main.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 6df2bd7..40956c2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -270,10 +270,11 @@ fn main() -> anyhow::Result<()> { println!("run it with: aur-build run {id}"); Ok(()) } - Err(stale) => { + Err(ap::ApproveError::Stale(stale)) => { eprintln!("refused: {stale}"); std::process::exit(2) } + Err(ap::ApproveError::System(e)) => Err(e.into()), } } Cmd::Reject { candidate, note } => { -- cgit v1.2.3