Skip to content

Commit 3ccebf7

Browse files
authored
Stop logging CheckPath returns error: context canceled (#21064)
We should only log CheckPath errors if they are not simply due to context cancellation - and we should add a little more context to the error message. Fix #20709 Signed-off-by: Andrew Thornton <[email protected]>
1 parent 94037ad commit 3ccebf7

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

modules/git/repo_attribute.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ func (c *CheckAttributeReader) Run() error {
191191
// CheckPath check attr for given path
192192
func (c *CheckAttributeReader) CheckPath(path string) (rs map[string]string, err error) {
193193
defer func() {
194-
if err != nil {
195-
log.Error("CheckPath returns error: %v", err)
194+
if err != nil && err != c.ctx.Err() {
195+
log.Error("Unexpected error when checking path %s in %s. Error: %v", path, c.Repo.Path, err)
196196
}
197197
}()
198198

services/gitdiff/gitdiff.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,8 +1178,6 @@ func GetDiff(gitRepo *git.Repository, opts *DiffOptions, files ...string) (*Diff
11781178
} else if language, has := attrs["gitlab-language"]; has && language != "unspecified" && language != "" {
11791179
diffFile.Language = language
11801180
}
1181-
} else {
1182-
log.Error("Unexpected error: %v", err)
11831181
}
11841182
}
11851183

0 commit comments

Comments
 (0)