fix(db): fail invite repair when validation remains nonzero

Co-authored-by: Honor <e0bf479eeebe47dde1e35705212a4df70616a7bc834d907ddfb18cf0405f8b1b@seiler-test.communities.public.builderlabstaging.xyz>
Signed-off-by: Brad Seiler <seiler@squareup.com>
This commit is contained in:
Brad Seiler
2026-11-09 15:41:41 -08:00
committed by GitHub
parent 0ffdda448a
commit 0252728a00
2 changed files with 11 additions and 8 deletions

View File

@@ -446,12 +446,7 @@ pub(super) async fn run_invite_repair_script(pool: &PgPool) -> String {
String::from_utf8_lossy(&output.stdout),
String::from_utf8_lossy(&output.stderr),
);
let stdout = String::from_utf8_lossy(&output.stdout).into_owned();
assert!(
stdout.lines().any(|line| line.trim() == "0"),
"repair validation did not return zero unrepaired invites:\n{stdout}"
);
stdout
String::from_utf8_lossy(&output.stdout).into_owned()
}
async fn invite_revocation_state(pool: &PgPool) -> Vec<(Uuid, Option<DateTime<Utc>>, bool)> {

View File

@@ -148,7 +148,7 @@ $$;
-- Expected result: 0. Every legacy marker in an active community has been
-- examined and cleared; every currently active ban has durably revoked its
-- invite. Markers in fenced communities remain for a later repair run.
SELECT count(*) AS unrepaired_invites
SELECT count(*) AS unrepaired_invites, count(*) = 0 AS repair_complete
FROM relay_invites AS invite
JOIN communities AS community ON community.id = invite.community_id
CROSS JOIN LATERAL (
@@ -182,4 +182,12 @@ WHERE community.deletion_state = 'active'
OR restriction.ban_expires_at > clock_timestamp())
)
)
);
)\gset
\echo unrepaired_invites
\echo :unrepaired_invites
\if :repair_complete
\else
DO $$ BEGIN
RAISE EXCEPTION 'invite repair incomplete; keep admission closed and rerun';
END $$;
\endif