Nobody Panic (please). #1244
Replies: 2 comments 5 replies
-
I didn't see this at the time. Sorry! I agree with this completely. But apart from enforcing this among regular committers in a friendly way, how should we communicate this expectation to new / occasional contributors? I already mentioned activating the |
Beta Was this translation helpful? Give feedback.
-
To add a bit of nuance, since I was against this in #1233 (comment): I'm wary of permanently adding an error variant saying "this failed because of an invalid geometry (but not all invalid inputs will fail), an implementation limitation or bug, or maybe because of catastrophic loss of precision, so try with Of course, for long-standing bugs that users keep hitting, either documenting the panic, or returning |
Beta Was this translation helpful? Give feedback.
-
There are different ideas about when it's considered acceptable to panic. A lot of that depends on the life cycle of the software. For example, I use
todo!
all the time while I'm building out a feature in a branch, or I'll lob an overly cockyunwrap
intomain
for some of my personal / prototype projects.I feel that
georust/geo
has moved well beyond "prototype" status at this point, but I realized that we never actually talked about what our expectations are around panic'ing, so as a first step, I want to share my own thoughts in hopes of building a shared understanding.tldr; Outside of documented
#Panic
usage, geo code should never panic, and we should not accept a PR that panics.To clarify a couple things:
unwrap
(or preferablyexpect
) in cases which truly can never happen can simplify code — this is a good usage ofpanic
.assert!
anddebug_assert!
are great tools and we should use them (in line with the rest of this rant).What I'm talking about is the expectations of completion for contribution.
For example, let's say I open a PR to merge in my new feature:
Firstly, I know the example is dumb. I'm sorry. But I think the "cases" are emblematic.
My own opinion is that only documented panics (case 1) and truly unreachable code (case 5) should use
panic
.Case 3 should not be considered for merging. It's a
todo!
that belongs only in a development branch, not a PR that is "ready for review".Case 4 is almost surely not OK. I might personally consider it reasonable depending on the exact circumstance, but probably not. In any case it would need to be called out and documented to the user under a
# Panics
heading.No other panics should be considered for merging - please do not open pull requests that panic without explanation of the panic.
The reason I'm saying this is because I end up doing a lot of code reviews for this library, and I don't know where the other person is coming from. Especially because a lot of people only contribute once or twice, so I never get a chance to learn their habits. But, to be fair, we have never set explicit expectations about this before.
I know that sometimes people open PR's just to get some feedback before they complete their programming work. That's also ok! I'm not trying to be an overly pedantic process butthead. But recognize that it's impossible to distinguish the case of "I'll fix this before I merge" from when someone is trying to merge "broken" code unless they say so.
For example I once merged a
case 3
thinking it was acase 5
precisely because the code said "this does not happen." and the submitter didn't call it out. So I figured, great, "this does not happen". Well it did happen and it crashed for people, and I'm still salty about it.I'm not sad because the code had a bug (hey, it happens!), I'm sad because I think the person actually knew it was a
case 3
. I don't think they were trying to sneak it by me or anything, they just had a different idea about what the quality expectation was for the library. They helped move a feature along that worked 80% of the way and crashed on the yet to be handled case. They moved the ball down the field, and I'm grateful for that.If I had understood that at the time, I would have left the PR open, or finished it myself rather than merging code which knowingly crashed our downstream users code. Crashing makes downstream users not trust geo, and makes me not comfortable recommending that people use it.
I realize that some of this concern can feel really over blown if you are only ever using georust for prototypes or a one off command line analysis or something, but georust is also being used (by me and others!) in remote production deployments like mobile apps, which can't be trivially patched. If a bug is discovered after deployment, I can fix my source code, but I have to go through a build, upload, and approval process and then wait for all my clients to update whenever they get around to it. In the meanwhile, my software is just broken for them.
And also, I want to be able to be proud of this thing that we've all worked on, and that's easier to do when we're on the same page about what the expected limitations are.
I'd just like to reiterate one last time: I'm not ranting about errors in geo. I actually I think we're generally doing a pretty good job on that front. I just want to see if we're mostly already on the same page, or willing to be on the same page, about what our expectations are for code coming into geo/geo-types, and I guess now geo-traits in terms of quality / completion for code that we accept into the project.
Sorry for the long winded essay.
Beta Was this translation helpful? Give feedback.
All reactions