-
Notifications
You must be signed in to change notification settings - Fork 42
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
refactor(i): Lint casts & move panics under must
funcs
#3134
base: develop
Are you sure you want to change the base?
refactor(i): Lint casts & move panics under must
funcs
#3134
Conversation
1bcee1c
to
1b8b14e
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3134 +/- ##
===========================================
- Coverage 78.10% 77.79% -0.31%
===========================================
Files 354 354
Lines 34660 34678 +18
===========================================
- Hits 27071 26977 -94
- Misses 5972 6064 +92
- Partials 1617 1637 +20
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 15 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
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.
todo: This appears to be entirely untested, given the lack of any changes made to test files, and no note of any manual testing in the PR description. I prefer that you add tests, but if you really think manual testing is okay in the short term, please note why.
I also have a question RE the linter excluded file list.
Happy to add tests if you have any specific code blocks that I should test, here are all the changes that have been done:
|
It was this I was mostly after - might not be worth the hassle of writing tests for though as I guess it is mostly just the http status code that changed, and that's not something the integration test framework can handle atm I think. Have you manually tested this? |
responseJSON(rw, http.StatusBadRequest, errorResponse{NewErrFailedToGetContext("db")}) | ||
return | ||
} | ||
db := mustGetContextClientDB(req) |
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.
question: Why is this turned into a must
instead of a try
like what you did is some other handles?
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.
Only one that remained a try
(not panic) is the P2P one because I think in that case it makes sense because P2P might be turned off and I see that specific error being returned by original author of the p2p code as useful for that situation as useful.
Rest all context casts are converted to a must
.
|
||
dsTxn, ok := txVal.(datastore.Txn) | ||
if !ok { | ||
responseJSON(rw, http.StatusBadRequest, errorResponse{ErrInvalidDataStoreTransaction}) |
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.
todo: This isn't a BadRequest
but rather an InternalServerError
(500).
Out of scope of this PR but a lot of our returned statuses are wrong like this. I create #3139 to track this. If a panic within the handlers automatically returns a 500 status then it might be better to just do a must
typecast and let the server panic for cases where a 500 is appropriate.
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.
Actually #3139 seems similar / duplicate of what I wanted #3103 to be originally (if i understand correctly) . So I would say that is very much in the scope of this PR. I can change all the required BadRequests
that need changing if you can guide me to which additional ones should be changed (@nasdf suggested only for the context
gets+casts originally), I can take care of them in this PR.
Manually some yes, but not all. I am a bit unsure how to test certain situations. |
19c5438
to
77bdcdb
Compare
must
ify
must
ifymust
ify panics
must
ify panicsmust
ify panic casts
77bdcdb
to
43ade30
Compare
must
ify panic castsmust
ify panic casts
must
ify panic castsmust
must
must
must
must
funcs
must
funcsmust
funcs
must
funcsmust
funcs
must
funcsmust
funcs
must
funcsmust
funcs
43ade30
to
ec7e43d
Compare
must
funcsmust
funcs
Relevant issue(s)
Resolves #3103
Description
must
functions