-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Prevent panic on error whilst getting storage #13164
Prevent panic on error whilst getting storage #13164
Conversation
* The `.Use` of storageHandler before setting up the template renderer causes a panic if there is an error to log. * The error passed to `ctx.Error` in that case may contain sensitive information and should not be rendered to the end user. We should instead log the error and render a simple error message. * There is no handling of missing avatars and this needs a 404. Minio errors need to be mapped to standard golang errors such as os.ErrNotExist. * There is no logging when storage is set up. Related go-gitea#13159 Signed-off-by: Andrew Thornton <art27@cantab.net>
I have not marked this a fixing #13159 because I am uncertain as to the root of their errors. It could simply be that the default location for avatars is now different but I think we looked very carefully at that to prevent that. Unfortunately there was no logging so we cannot be sure what the configuration is. This PR now adds some logging. |
Codecov Report
@@ Coverage Diff @@
## master #13164 +/- ##
=======================================
Coverage 42.04% 42.04%
=======================================
Files 681 681
Lines 75145 75173 +28
=======================================
+ Hits 31596 31609 +13
- Misses 38393 38410 +17
+ Partials 5156 5154 -2
Continue to review full report at Codecov.
|
Damn damn damn. I got the error conversion incorrect here - this'll teach me for not actually making unit tests! We should be mostly converting to os.PathError and checking that instead of plain os errors. |
@zeripath I think, at this point we can invent a new error strukts ourselve :) |
I think if we just use errors.Is(err, os.ErrNotExist) then we can keep the convert very simple. |
Unfortunately there was a mistake in go-gitea#13164 which fails to handle os.PathError wrapping an os.ErrNotExist Signed-off-by: Andrew Thornton <art27@cantab.net>
…ments-in-pull-request-label-style * origin/master: [skip ci] Updated translations via Crowdin Fix diff skipping lines (go-gitea#13154) Update go-version v1.2.3 -> v1.2.4 (go-gitea#13169) Vendor Update Go Libs (go-gitea#13166) Prevent panics with missing storage (go-gitea#13164) Improve users management through the CLI (go-gitea#6001) (go-gitea#10492) Change order of possible-owner organizations to alphabetical (go-gitea#13160) Slightly simplify the queue settings code to help reduce the risk of problems (go-gitea#12976) [Vendor] Update go-ldap to v3.2.4 (go-gitea#13163) [skip ci] Updated translations via Crowdin Update external-renderers.en-us.md (go-gitea#13165)
Unfortunately there was a mistake in #13164 which fails to handle os.PathError wrapping an os.ErrNotExist Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
…ea#13178) Unfortunately there was a mistake in go-gitea#13164 which fails to handle os.PathError wrapping an os.ErrNotExist Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Backport sent. It is #13193 |
Signed-off-by: Andrew Thornton <art27@cantab.net>
* Fix Storage mapping (#13297) Backport #13297 This PR fixes several bugs in setting storage * The default STORAGE_TYPE should be the provided type. * The Storage config should be passed in to NewStorage as a pointer - otherwise the Mappable interface function MapTo will not be found * There was a bug in the MapTo function. Fix #13286 Signed-off-by: Andrew Thornton <art27@cantab.net> * add missing changes from backport #13164 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
.Use
of storageHandler before setting up the template renderercauses a panic if there is an error to log.
ctx.Error
in that case may contain sensitiveinformation and should not be rendered to the end user. We should
instead log the error and render a simple error message.
errors need to be mapped to standard golang errors such as
os.ErrNotExist.
Related #13159
Signed-off-by: Andrew Thornton art27@cantab.net