Skip to content

fix: grpc error handling for TemplateChart req #4980

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

Merged
merged 4 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions api/helm-app/service/HelmAppService.go
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,9 @@ func (impl *HelmAppServiceImpl) TemplateChart(ctx context.Context, templateChart
if err != nil {
impl.logger.Errorw("error in templating chart", "err", err)
clientErrCode, errMsg := util.GetClientDetailedError(err)
if clientErrCode.IsFailedPreconditionCode() {
return nil, &util.ApiError{HttpStatusCode: http.StatusUnprocessableEntity, Code: strconv.Itoa(http.StatusUnprocessableEntity), InternalMessage: errMsg, UserMessage: errMsg}
}
if clientErrCode.IsInvalidArgumentCode() {
return nil, &util.ApiError{HttpStatusCode: http.StatusConflict, Code: strconv.Itoa(http.StatusConflict), InternalMessage: errMsg, UserMessage: errMsg}
}
Expand All @@ -979,6 +982,13 @@ func (impl *HelmAppServiceImpl) GetNotes(ctx context.Context, request *gRPC.Inst
response, err := impl.helmAppClient.GetNotes(ctx, request)
if err != nil {
impl.logger.Errorw("error in fetching chart", "err", err)
clientErrCode, errMsg := util.GetClientDetailedError(err)
if clientErrCode.IsFailedPreconditionCode() {
return notesTxt, &util.ApiError{HttpStatusCode: http.StatusUnprocessableEntity, Code: strconv.Itoa(http.StatusUnprocessableEntity), InternalMessage: errMsg, UserMessage: errMsg}
}
if clientErrCode.IsInvalidArgumentCode() {
return notesTxt, &util.ApiError{HttpStatusCode: http.StatusConflict, Code: strconv.Itoa(http.StatusConflict), InternalMessage: errMsg, UserMessage: errMsg}
}
return notesTxt, err
}
notesTxt = response.Notes
Expand Down
3 changes: 3 additions & 0 deletions pkg/generateManifest/DeployementTemplateService.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@ func (impl DeploymentTemplateServiceImpl) GenerateManifest(ctx context.Context,
if err != nil {
impl.Logger.Errorw("error in templating chart", "err", err)
clientErrCode, errMsg := util.GetClientDetailedError(err)
if clientErrCode.IsFailedPreconditionCode() {
return nil, &util.ApiError{HttpStatusCode: http.StatusUnprocessableEntity, Code: strconv.Itoa(http.StatusUnprocessableEntity), InternalMessage: errMsg, UserMessage: errMsg}
}
if clientErrCode.IsInvalidArgumentCode() {
return nil, &util.ApiError{HttpStatusCode: http.StatusConflict, Code: strconv.Itoa(http.StatusConflict), InternalMessage: errMsg, UserMessage: errMsg}
}
Expand Down
Loading