inetaf / netaddr

Network address types
BSD 3-Clause "New" or "Revised" License
712 stars 40 forks source link

IPSet mysteriously does nothing on invalid inputs #141

Open danderson opened 3 years ago

danderson commented 3 years ago

If I AddRange an invalid range, IPSet does nothing, successfully. This is surprising, a more normal idiom in Go would be to have AddRange return an error, and have a MustAddRange that panics if you really want a shorthand.

It does make the builder more annoying to wield, since a bunch of common adders/removers can now fail, but that feels better to me than silently doing something surprising.

josharian commented 3 years ago

Both this (return an error instead of swallowing invalid input to IPSetBuilder) and the direction in #167 (fix an invalid input to IPPrefixFrom rather than return an error) feel locally reasonable, but they conflict philosophically. I'm not sure what the resolution is, but I'm not very comfortable about it.

josharian commented 3 years ago

Oh, and I see this is also now being discussed in #178. :)

bradfitz commented 3 years ago

I replied on #178 then.

danderson commented 3 years ago

Yeah, the resolution of this will be subsumed by what we decide our global behavior should be.