fix(admin): report real outcome of ten admin mutations (BUNYIP-398) #391
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/BUNYIP-398-admin-false-success"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Ten admin mutation handlers in
bunyip-web/src/handlers/admin.rsnow report the real outcome of their API call instead of always redirecting as success.Why
Each of these handlers did
let _ = admin_api::...(...).await;followed by an unconditional successredirect_cookies(...). If the API or transport call failed (network error, downstream 5xx, validation rejection) the operator saw a success redirect while the destructive operation (delete user, revoke lifetime, revoke membership, delete application group, delete doc, etc.) never happened, with no error shown and no log at the site. Silent false-success on destructive operations is a real trust and correctness problem (BUNYIP-398).Changes
let target = match admin_api::...(...).await { Ok(_) => <existing success target>, Err(e) => { tracing::warn!(...); format!("...?toast_err={}", urlenc("...")) } };thenredirect_cookies(&target, &c.set_cookies); the Ok arm preserves the exact prior success redirect so successful calls are unchanged.?toast_err=flash convention (drained by the global toast system inbunyip-web/src/views/layout.rs), matching the closest non-discarding neighbors in the same module (user_email,user_verify_email,user_reset_2fa,unban_ip,reset_rate_limit).tracing::warn!(<id> = %<id>, error = ?e, "admin <op> failed")with the primary identifier of the mutated entity;error = ?ebecauseApiErrorderivesDebug(notDisplay) and its Debug output carries status, code, and message.user_role(update_user_role),user_delete,user_suspend,user_revoke_lifetime,membership_revoke,application_field(update_application),application_group_delete,application_doc_create,application_doc_update,application_doc_delete.let _ = admin_api::sites in this module that the issue does not enumerate (reactivate_user, admin_reset_password, grant_lifetime, grant_membership, swap_application_order, set_application_group, set_application_restricted) are left unchanged.Tests
ghcr.io/niceguyit/rust-builder-glibc:v1.0.1-rust1.94-trixie,SQLX_OFFLINE=true):cargo fmt --all --checkclean,cargo clippy --workspace --all-targets -- -D warningsclean,cargo test --workspace --all-targetsgreen (493 tests passed, 0 failed). No live Postgres required.