Repository navigation
Conversation
DirSize ignores the error its filepath.Walk callback is handed. When the root cannot be stat-ed, filepath.Walk calls the callback with a nil FileInfo, so info.IsDir() dereferences nil and the process panics. This is reachable from the admin dashboard: calculateStorage walks serviceConfig.UploadPath and explicitly logs and swallows the error it expects back, so a missing or unmounted upload directory turns the request into a panic instead of the intended "size unknown" path. Handle the callback error before touching info.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #
Proposed Changes
pkg/dir.DirSizenow checks the error itsfilepath.Walkcallback is given before it uses theFileInfo.filepath.Walkpasses a nilinfowhen the root cannot be stat-ed, so a missing path used to raiseinvalid memory address or nil pointer dereferenceinstead of returning the error.calculateStorage(internal/service/dashboard/dashboard_service.go:334) already logs and swallows an error fromDirSize; with the panic that branch was unreachable, so a missing or unmounted upload directory turned the dashboard into a crash rather than an empty size.pkg/dir/dir_test.go: the happy path plus three missing-path cases that must return an error and must not panic.Additional Info
Reproducer on
main(6744295):dir.DirSize("/no/such/dir")panics with SIGSEGV atpkg/dir/dir.go:45. After the change it returns thelstat …: no such file or directoryerror. No new dependency;
golangci-lint v2.6.2(make lint) andgo mod tidyare clean.