Skip to content
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

Handle and propagate errors when checking if paths are Dirs, Files or Exist #13186

Conversation

zeripath
Copy link
Contributor

com.IsFile and the like although simple do elide the difference with errors on filesystem reads and may cause incorrect intepretations.

This PR switches all uses of from com.Is* to util.Is* and makes a best guess as to what to do - mostly log and propagate the error up.

This may make some misbehaving systems and OSs appear less stable but ... at least the problems are not being elided anymore.

Fix #13175

(I'm calling this a fix for that issue because although I do not know what is behind the underlying issue here - a new bug report with logs following on from this change would be more useful.)

@zeripath zeripath added this to the 1.14.0 milestone Oct 17, 2020
modules/templates/static.go Outdated Show resolved Hide resolved
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Oct 17, 2020
modules/templates/static.go Outdated Show resolved Hide resolved
Copy link
Contributor Author

@zeripath zeripath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missed returns post ctx.ServerError

routers/admin/repos.go Show resolved Hide resolved
routers/api/v1/admin/adopt.go Show resolved Hide resolved
routers/api/v1/admin/adopt.go Show resolved Hide resolved
routers/repo/repo.go Outdated Show resolved Hide resolved
routers/user/setting/adopt.go Show resolved Hide resolved
routers/repo/repo.go Outdated Show resolved Hide resolved
@rozhuk-im
Copy link

if err == nil && !isExist {
or else if !isExist {
looks like I mark all suspect places.
In few places I found double error logging, but it is ok :)

@rozhuk-im
Copy link

rozhuk-im commented Oct 19, 2020

IMHO in future other devs will make same errors, due to bad API design.
To prevent coding errors - better to change API to return not bool but enum: Exist, NotExist, Error and err.

@zeripath
Copy link
Contributor Author

@rozhuk-im that is not idiomatic for go.

@rozhuk-im
Copy link

rozhuk-im commented Oct 19, 2020

TaskStatusRunning // 1 task is running

Probably, but similar things are used.

@codecov-io
Copy link

codecov-io commented Oct 20, 2020

Codecov Report

Merging #13186 (84cdce4) into master (3f13e07) will decrease coverage by 0.05%.
The diff coverage is 23.93%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #13186      +/-   ##
==========================================
- Coverage   42.25%   42.19%   -0.06%     
==========================================
  Files         697      697              
  Lines       76631    76825     +194     
==========================================
+ Hits        32377    32416      +39     
- Misses      38932    39061     +129     
- Partials     5322     5348      +26     
Impacted Files Coverage Δ
cmd/dump.go 0.88% <0.00%> (-0.03%) ⬇️
cmd/web.go 0.00% <0.00%> (ø)
models/upload.go 0.00% <0.00%> (ø)
modules/auth/repo_form.go 39.83% <0.00%> (-1.77%) ⬇️
modules/git/hook.go 52.30% <0.00%> (-3.44%) ⬇️
modules/repository/adopt.go 0.00% <0.00%> (ø)
modules/repository/check.go 0.00% <0.00%> (ø)
modules/repository/generate.go 0.00% <0.00%> (ø)
modules/repository/hooks.go 19.64% <0.00%> (-1.72%) ⬇️
modules/setting/lfs.go 40.90% <0.00%> (-3.00%) ⬇️
... and 17 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3f13e07...84cdce4. Read the comment docs.

@GiteaBot GiteaBot removed the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Nov 8, 2020
@GiteaBot GiteaBot added the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label Nov 8, 2020
@6543
Copy link
Member

6543 commented Nov 19, 2020

@zeripath can you resolve the conflicts?

@zeripath
Copy link
Contributor Author

@6543 Conflicts resolved

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Nov 24, 2020
@lafriks
Copy link
Member

lafriks commented Nov 24, 2020

Tests fail

techknowlogick and others added 3 commits November 25, 2020 15:08
The previous merge managed to break repo_form.go

Signed-off-by: Andrew Thornton <art27@cantab.net>
@zeripath
Copy link
Contributor Author

Agh ! it looks like when I resolved conflicts I introduced a bug in repo_form.go. Should now be fixed.

@lafriks
Copy link
Member

lafriks commented Nov 27, 2020

🚀

@techknowlogick
Copy link
Member

🚀

@techknowlogick techknowlogick merged commit 742e21a into go-gitea:master Nov 28, 2020
@zeripath zeripath deleted the fix-13175-switch-to-report-errors-on-checking-exists branch November 28, 2020 05:07
@go-gitea go-gitea locked and limited conversation to collaborators Jan 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cron tasks can not find git repos time to time
7 participants