From 92e0f8f10ef45c28a0de4398a7627a333cec77fa Mon Sep 17 00:00:00 2001 From: Hannes Gustafsson Date: Mon, 28 Oct 2024 11:28:52 +0000 Subject: [PATCH] Return error when unable to read configuration Prior when the configuration was not successfully fetched, the error was only logged but execution continued. Not fetching the configuration is an unrecoverable error that should result in upstream failure. Instead return the error to caller and let them log it. --- internal/pkg/githubapi/github.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/pkg/githubapi/github.go b/internal/pkg/githubapi/github.go index d3cfdb33..5cb41596 100644 --- a/internal/pkg/githubapi/github.go +++ b/internal/pkg/githubapi/github.go @@ -189,7 +189,7 @@ func handleShowPlanPREvent(ctx context.Context, ghPrClientDetails GhPrClientDeta defaultBranch, _ := ghPrClientDetails.GetDefaultBranch() config, err := GetInRepoConfig(ghPrClientDetails, defaultBranch) if err != nil { - ghPrClientDetails.PrLogger.Infof("Couldn't get Telefonistka in-repo configuration: %v", err) + return fmt.Errorf("get in-repo configuration: %w", err) } promotions, _ := GeneratePromotionPlan(ghPrClientDetails, config, *eventPayload.PullRequest.Head.Ref) commentPlanInPR(ghPrClientDetails, promotions) @@ -205,7 +205,7 @@ func handleChangedPREvent(ctx context.Context, mainGithubClientPair GhClientPair defaultBranch, _ := ghPrClientDetails.GetDefaultBranch() config, err := GetInRepoConfig(ghPrClientDetails, defaultBranch) if err != nil { - ghPrClientDetails.PrLogger.Infof("Couldn't get Telefonistka in-repo configuration: %v", err) + return fmt.Errorf("get in-repo configuration: %w", err) } if config.Argocd.CommentDiffonPR { componentPathList, err := generateListOfChangedComponentPaths(ghPrClientDetails, config)