-
Notifications
You must be signed in to change notification settings - Fork 26
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
Add more information to the error message log #236
base: master
Are you sure you want to change the base?
Conversation
glower
commented
Jun 13, 2019
- Add detailed information about the error to the error response
Codecov Report
@@ Coverage Diff @@
## master #236 +/- ##
==========================================
+ Coverage 48.78% 48.93% +0.14%
==========================================
Files 90 90
Lines 4747 4745 -2
==========================================
+ Hits 2316 2322 +6
+ Misses 2211 2206 -5
+ Partials 220 217 -3
Continue to review full report at Codecov.
|
This is a possible fix for #235 |
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.
Generally snapd should do something semi-reasonable if error cases come as application/json with a "message" field. That seems to be the case here.
@@ -346,7 +346,8 @@ func findModel(brandID, modelName, serialNumer, apiKey string) (datastore.Model, | |||
// Validate the model by checking that it exists on the database | |||
model, err := datastore.Environ.DB.FindModel(brandID, modelName, apiKey) | |||
if err != nil { |
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.
because of the try FindModel and then otherwise on failure eagerly try GetSubstoreModel it seems - as it was already - this will always produce slightly odd error messages/responses, this isn't new but if the goal is making for more understandable errors for the brand user this might need a larger rethink
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 will drop this PR and only put more info inside of the internal log. We can have a separate conversation about error responses.
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.
I would ask @cprov whether the change here is already enough of an improvement, he was the one having trouble debugging, before dropping them. For more clarity the issue here is how apiKey is checked implicitly in one case but not the other, I don't know the detail of the data model and other usages enough but in principle it would be better if the apiKey check was explicit/distinguishable unless we think leaking whether a model really exists or not is deemed a problem.
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.
Yes, I agree on that, but in this case, I just wanted to improve logging, not touching any business logic at all.