From 0bd1e99ac921dc3f3b5a1edb6fd0519f3a893eaa Mon Sep 17 00:00:00 2001 From: Leandro Poroli Date: Tue, 2 Jan 2024 12:24:24 -0300 Subject: [PATCH] adding GH rate limits logs --- .../validation/rules/valid_package_icon_rule.go | 8 +++++++- catalog-validator/validation/rules/valid_package_rule.go | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/catalog-validator/validation/rules/valid_package_icon_rule.go b/catalog-validator/validation/rules/valid_package_icon_rule.go index 45abfb1..e653125 100644 --- a/catalog-validator/validation/rules/valid_package_icon_rule.go +++ b/catalog-validator/validation/rules/valid_package_icon_rule.go @@ -2,6 +2,7 @@ package rules import ( "context" + "errors" "fmt" "github.com/google/go-github/v54/github" "github.com/kurtosis-tech/kurtosis-package-indexer/server/catalog" @@ -120,7 +121,12 @@ func (validPackageIconRule *validPackageIconRule) getPackageIconImageConfig(ctx // having the icon is not mandatory return nil, nil } - return nil, stacktrace.Propagate(err, "an error occurred reading content of Kurtosis Package '%s' - file '%s'", packageName, packageIconFilepath) + errMsj := fmt.Sprintf("an error occurred reading content of Kurtosis Package '%s' - file '%s'", packageName, packageIconFilepath) + if errors.Is(err, &github.RateLimitError{}) { + errMsj = "GitHub API rate limit exceeded." + logrus.Errorf("%s Error is:\n%v", errMsj, err.Error()) + } + return nil, stacktrace.Propagate(err, errMsj) } rawPackageIconContentStr, err := packageIconFileContentResult.GetContent() diff --git a/catalog-validator/validation/rules/valid_package_rule.go b/catalog-validator/validation/rules/valid_package_rule.go index bab1097..0c4ad05 100644 --- a/catalog-validator/validation/rules/valid_package_rule.go +++ b/catalog-validator/validation/rules/valid_package_rule.go @@ -2,6 +2,7 @@ package rules import ( "context" + "errors" "fmt" "github.com/google/go-github/v54/github" "github.com/kurtosis-tech/kurtosis-package-indexer/server/catalog" @@ -87,7 +88,12 @@ func (validPackageRule *validPackageRule) getPackageNameFromKurtosisYmlFile(ctx if err != nil && resp != nil && resp.StatusCode == http.StatusNotFound { return "", stacktrace.NewError("No '%s' file for package '%s'", kurtosisYamlFilepath, packageName) } else if err != nil { - return "", stacktrace.Propagate(err, "An error occurred reading content of Kurtosis Package '%s' - file '%s'", packageName, kurtosisYamlFilepath) + errMsj := fmt.Sprintf("An error occurred reading content of Kurtosis Package '%s' - file '%s'", packageName, kurtosisYamlFilepath) + if errors.Is(err, &github.RateLimitError{}) { + errMsj = "GitHub API rate limit exceeded." + logrus.Errorf("%s Error is:\n%v", errMsj, err.Error()) + } + return "", stacktrace.Propagate(err, "%s", errMsj) } kurtosisYaml, err := parseKurtosisYaml(kurtosisYamlFileContentResult)