-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Snapshot errors include source in Display #34799
Snapshot errors include source in Display #34799
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #34799 +/- ##
=========================================
- Coverage 81.8% 81.8% -0.1%
=========================================
Files 823 823
Lines 222713 222713
=========================================
- Hits 182337 182254 -83
- Misses 40376 40459 +83 |
@@ -413,7 +414,7 @@ pub enum AddBankSnapshotError { | |||
#[error("bank snapshot dir already exists: {0}")] | |||
SnapshotDirAlreadyExists(PathBuf), | |||
|
|||
#[error("failed to create snapshot dir: {0}")] | |||
#[error("failed to create snapshot dir: {0}: {}", .0.source().unwrap())] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are these unwraps safe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Errors from fs-err
always contains a source
, so calling .source()
on any error generated from fs-err
will always be Some
. I went through and audited all uses of these snapshot errors and confirmed they all come from fs-err
functions. Therefore they'll always have a source, and the unwrap is safe.
Would it be good to add that into the code as a comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but the api returns Option<T>
. a comment in our code won't stop upstream from starting to return None
in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. My thought was that this PR would be backported to v1.17, which if I understand correctly, we do not bump dependencies anymore. So the upstream fs-err won't change and thus won't start returning None
.
Then in master
I can do a more thorough fix, so as to avoid larger code changes needing to be backported.
I'm happy to go either way here! Do you have a suggested game plan for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me, I'd rather avoid backporting something with these unwraps, same concerns as Trent. Better error messaging is great, but don't think it's a critical fix that needs immediate backporting - especially given the possibility of unwrapping a none.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll close this PR. Thanks for the input, folks!
Closing. This PR is not the desired solution to the problem. |
i'd still like to see something done about the useless error messages that |
The fs-err messages aren't useless though, as it indicates the fs/io operation that failed and the paths. Previously, this was either (1) entirely missing from the error, or (2) manually added via a The fs-err Errors still contain the source error, but are not output as part of Display. So when we changed the snapshot processing/AccountsBackgroundService to return Errors and log them, instead of panicking, we changed the output from Debug to Display. Those two changes combined are why now we don't get the underlying fs error in the log. The right fix is to include the underlying (aka source) error when logging. The std lib actually has a way to do exactly that, |
Problem
When printing with
Display
, some snapshot errors do not include their source due to fs-err. This results in errors like this:Note that this error message does not include why the hard linking failed...
Summary of Changes
For all snapshot errors that use
fs-err
, we know they include a populatedsource
field. Thus, we know that.source()
will always returnSome
.I don't love this solution, but it is simple and safe. I'd like to backport this to v1.17, and then do a follow-up PR to fix this properly in master. This plan allows us to have the smallest patch to v1.17.