feat: keep a mailbox removal pass's matched, remaining, removed, dry_run and per-mailbox error fields in warmblyctl's redacted admin output so an operator can see failures and when to stop

This commit is contained in:
Matthew Meszaros
2026-11-12 17:54:34 +01:00
parent b47da7014e
commit 63a4bb77bb
2 changed files with 21 additions and 0 deletions
+1
View File
@@ -24,6 +24,7 @@ func remoteWordSet(words string) map[string]bool {
// Unknown fields and free text fail closed, including newly added backend fields.
var remoteOutputFields = remoteWordSet(`
data pagination summary permissions user organization workers nodes mailboxes
matched remaining removed dry_run error
commands results metrics broker partitions topics consumer_group topic events capture
generic_error_coverage generic_error_reason
sources counts health totals failing_endpoints jobs plans discounts members roles
+20
View File
@@ -792,3 +792,23 @@ func TestRemoteCatalogMatchesActualAdminRoutesAndGuards(t *testing.T) {
}
}
}
func TestRemoteOutputKeepsMailboxRemovalProgress(t *testing.T) {
id := "6f1c2d3e-4b5a-4c6d-8e7f-0a1b2c3d4e5f"
out := redactRemoteJSON("", map[string]any{
"dry_run": false, "matched": float64(3), "removed": float64(1), "failed": float64(1), "remaining": float64(2),
"mailboxes": []any{map[string]any{"id": id, "email": "a@example.com", "removed": false, "error": "provider said no"}},
}).(map[string]any)
for _, k := range []string{"dry_run", "matched", "removed", "failed", "remaining"} {
if _, ok := out[k]; !ok {
t.Fatalf("%s dropped from %v", k, out)
}
}
row := out["mailboxes"].([]any)[0].(map[string]any)
if row["id"] != id || row["removed"] != false || row["error"] != "[REDACTED]" {
t.Fatalf("mailbox row = %v", row)
}
if v, ok := row["email"]; ok && v != "[REDACTED]" {
t.Fatalf("address leaked: %v", row)
}
}