how large would the leaks have to be to counteract the positive effects?
Trying a ballpark estimate ... biogas replaces natural gas. For simplicity let's assume the replacement is 1:1, one mole of methane from biogas* replaces one mole of natural gas. This also means that one mole of biomethane "saves" one mole of CO2.
Methane is about 25 times more intensive in terms of cliamte change than CO2. So if 100/25 = 4% leaks, the positive effect would be offset.
The factors influencing gas leakage, from biggest to smallest influence (this is mostly from memory):
Retention time of substrate in gas tight system - depending on retention time in the digesters, the digestate could still have 10% or so of it's total biogas potential, when the digestate storage is open and the HRT is short. One of the later iterations of the German rennewable energy laws specifies 150 days retention time in the gas tight system for this reason & I think this is reasonable for many substrates.
Leaking foil roofs - foil roofs are common on large tanks, especially the connection foil roof/digester is a common point for leakage. This study found leakage rates from plants between 0 and 20 Nm³/h (median 5-10 Nm³/h), size of plants was not given but probably around 500 Nm³/h biogas production.
Methane slip - I don't have numbers to go by, but I think 0.5-1% of gas slip (unburnt gas in the exhaust) in IC motors is common. This regardless of wether you burn natural gas or biogas, AFAIK.
Manure storage - some wastes will ferment on their own, esp. manure.
Everything else - IMO the art of building gas pipes etc. is pretty well developed, if proper procedures are followed and proper materials used leakages from pipes should be neglible.
In summary, the methane loss of biogas plants may well be above the 4% cutoff point I mentioned above, or well below, depending on plant design and quality of building.
However, as you pointed out in comments to your question, you need to also look at what would happen to the feedstock without biogasification. Manure would ferment (but not as completely) in an open pit and emit gasses. Municipal wastes would be either incinerated (likely with additional fuel because of the high moisture content), composted or landfilled (landfilled wastes also ferment and produce biogas, if this goes to the atmosphere, is flared or used productivly depends on the site). I have worked in landfill supervision and design of biogas plants.
At this point, I lack good numbers to really compare biogasification to other disposal paths. Having worked in landfill supervision and design of biogas plants, I have more trust in a properly designed biogas plant to keep methane out of the atmosphere than in a typically, well maintained landfill. But I'm sure you can find shoddy biogas plants that leak, for the same amount of input, worse than some landfills!
Likewise, I'm still looking for hard numbers of fuel usage for incineration of biowastes, so I can't offer a good comparison here.
So IMO, while biogas from energy crops is highly questionable, biogasification of wastes is a net benefit if done properly.
*biogas is anything between 50 and 70% methane, the rest CO2 and traces.