Skip to content

Commit d4f2aac

Browse files
committed
fix(node): fail announce closed when withheld walk fails (#90)
A failed or panicked withheld_blob_oids walk left announce=true while withheld=None, so a push we could not vet would still gossip ref updates, notify peers, and write a permanent Arweave anchor. Force announce false in that arm so the gate fails closed on both axes.
1 parent 47e6903 commit d4f2aac

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

‎crates/gitlawb-node/src/api/repos.rs‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ const ZERO_SHA: &str = "0000000000000000000000000000000000000000";
3333
/// Returns `(announce, withheld)`: `announce` is whether the repo may be
3434
/// announced/replicated to the anonymous public at all (also gates gossip and
3535
/// Arweave anchoring downstream), and `withheld` is the anonymous withheld blob
36-
/// set when announceable (`None` when not announceable, or when the withheld
37-
/// walk failed — fail closed). Returning both keeps the gate's announce
38-
/// decision a single source rather than recomputing it at each call site.
36+
/// set when announceable (`None` when not announceable). A failed/panicked
37+
/// withheld walk fails closed on both axes: `announce` is forced false and
38+
/// `withheld` is `None`, so an unvetted push neither replicates blobs nor
39+
/// announces. Returning both keeps the gate's announce decision a single
40+
/// source rather than recomputing it at each call site.
3941
async fn replication_withheld_set(
4042
rules: Option<Vec<crate::db::VisibilityRule>>,
4143
owner_did: &str,
@@ -74,7 +76,14 @@ async fn replication_withheld_set(
7476
}
7577
None => None,
7678
};
77-
(announce, withheld)
79+
// Fail closed on a failed/panicked withheld walk: with `announce` already
80+
// true here, a `None` withheld can only mean the walk errored (rules are
81+
// necessarily `Some`, else we returned above). Suppress the announce too so
82+
// a push we couldn't vet does not gossip, notify peers, or anchor to Arweave.
83+
match withheld {
84+
Some(withheld) => (announce, Some(withheld)),
85+
None => (false, None),
86+
}
7887
}
7988

8089
// ── Request / Response types ───────────────────────────────────────────────

0 commit comments

Comments
 (0)