-
-
Notifications
You must be signed in to change notification settings - Fork 314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typing upload-pack ERR responses #200
Comments
Thanks for reporting, [rant] error handling around these pseudo-streaming-iterator line readers wrapped in impls of std::io::Read is definitely not nice and begging for some sort of rewrite once GATs are there or… a version that just copies the line around to make the borrow check issues go away right now. Maybe a case of premature optimization[/rant]. Looking into this more, even with GATs or without these borrow-check workarounds error handling might be difficult to do on the top-level there is this implementation of Understanding what's happeningFollowing the chain of errors bubbling up, it all starts with reading the packet line, where the server error is treated as string: There one could add a strongly typed error based on some well-known server messages. This should be fine as they are seemingly stable and not internationalized. Going up a level, the actual Ultimately, this makes for a Since server errors are certainly common, providing better support for that would be nice to allow retries or more resilient clients in general. Possible changesWhat' I could imagine doing would be to change the inner-most error contained in the Does that sound viable to you? If so quick confirmation is enough for me to implement this. |
Ah I see, thanks. That’s a bit tricky indeed - I was hoping that ERR responses would be handled one layer up. Because, technically an ERR is a valid pktline, but an error on the protocol level.
If that’s not a feasible refactor at this point, maybe a stopgap would be to wrap the err string in a `struct ErrResponse(BString)`? This would disambiguate any future uses of `io::ErrorKind::Other` + stringly value, but also avoid to commit on accidentally stable error strings in git.
I mean, my use of this is a bit unorthodox — I’m just short cutting ls-refs because the remote is supposed to serve a particular ref by convention. The response to an unknown want-ref is, well, “unknown ref”, which would normally be a client error. In our case, however, it means that this is a “bad” peer, and so I need to be able to distinguish this error from others.
Iow, I think ERR responses are semantically equivalent to panics, and I’m matching on it on my own risk. Most likely gitoxide doesn’t want to commit on returning the exact same error strings in the same cases as `git upload-pack`, so I think just distinguishing ERR responses from decoding or IO errors is what we’d want to end up with.
Wdyt?
|
That's true, it's just so much easier to have the option of transforming this into an error on
…wrapping it into a
Super interesting to know :)!
Great, that's easier to implement for sure. So the anticipated change would be something like this: |
By the way, are you already dealing with error
|
Right now it only works with 'ref-in-want', but in future it could actually act as a filter.
…for easier matching and figuring out what actually happened. For now, this is left entirely to users of the API, but one day I imagine that some parsing could be done on gitoxide's side as well.
This will allow creating issue links and to group by issue number.
By the way, are you already dealing with error source()es?
We’re using anyhow further up the stack, and often in tests, which mostly does the right thing. When the only choice is to log out an error, we’re using the Debug impl — that’s a bit suboptimal: at low verbosity, one would want to simply concatenate the Display strings along the chain, while at debug level the actual Debug is more useful.
Not sure how to deal with this. The tracing crate has a Value trait, but that is sealed for object safety reasons. They had announced a separate crate to deal with this problem, but I’m not sure if it’s stable yet.
|
worksforme Thanks! 🙏 |
It would indeed be nice to have a new formatter or utility to automatically walks the source chain of errors when generating a display string. Thanks to my none-existing experience with
Neat! Please let me know if you need a release right away, and if that should be only |
I have a test case which tries to fetch a ref the remote end doesn't know about:
The
Display
ed error message from this is "The server response could not be parsed".Debug
ging the error shows that it is two nestedio::Error
s.I couldn't quite figure out where to look, but it seems to me like the pktline reader should recognise this as a protocol message, and return a dedicated error variant for it.
"unknown ref" is of course still an arbitrary string, but it would still be helpful to be able to pattern match on those kinds of errors.
The text was updated successfully, but these errors were encountered: