From 0f860f05128efc7225f9619fa105bc5f7827d668 Mon Sep 17 00:00:00 2001 From: Arya Khochare <91268931+Aryakoste@users.noreply.github.com> Date: Mon, 14 Apr 2025 17:26:05 +0530 Subject: [PATCH] Fixed errcheck issues in server/channels/app/integration_action.go (#29040) Co-authored-by: Ben Schumacher --- server/.golangci.yml | 1 - server/channels/app/integration_action.go | 15 ++++++++++++++- server/i18n/en.json | 8 ++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/server/.golangci.yml b/server/.golangci.yml index 48a2e02964..26c1684465 100644 --- a/server/.golangci.yml +++ b/server/.golangci.yml @@ -95,7 +95,6 @@ issues: channels/app/file_test.go|\ channels/app/helper_test.go|\ channels/app/import_functions.go|\ - channels/app/integration_action.go|\ channels/app/permissions_test.go|\ channels/app/platform/helper_test.go|\ channels/app/platform/license.go|\ diff --git a/server/channels/app/integration_action.go b/server/channels/app/integration_action.go index 0d2a88158b..728a254af4 100644 --- a/server/channels/app/integration_action.go +++ b/server/channels/app/integration_action.go @@ -514,8 +514,21 @@ func (a *App) SubmitInteractiveDialog(c request.CTX, request model.SubmitDialogR } defer resp.Body.Close() + body, err := io.ReadAll(resp.Body) + if err != nil { + return nil, model.NewAppError("SubmitInteractiveDialog", "app.submit_interactive_dialog.read_body_error", nil, "", http.StatusInternalServerError).Wrap(err) + } + var response model.SubmitDialogResponse - json.NewDecoder(resp.Body).Decode(&response) // Don't fail, an empty response is acceptable + if len(body) == 0 { + // Don't fail, an empty response is acceptable + return &response, nil + } + + err = json.Unmarshal(body, &response) + if err != nil { + return nil, model.NewAppError("SubmitInteractiveDialog", "app.submit_interactive_dialog.decode_json_error", nil, "", http.StatusInternalServerError).Wrap(err) + } return &response, nil } diff --git a/server/i18n/en.json b/server/i18n/en.json index c6771a0ab7..7562bda0e0 100644 --- a/server/i18n/en.json +++ b/server/i18n/en.json @@ -6876,10 +6876,18 @@ "id": "app.status.get.missing.app_error", "translation": "No entry for that status exists." }, + { + "id": "app.submit_interactive_dialog.decode_json_error", + "translation": "Encountered an error decoding JSON response from interactive dialog submission." + }, { "id": "app.submit_interactive_dialog.json_error", "translation": "Encountered an error encoding JSON for the interactive dialog." }, + { + "id": "app.submit_interactive_dialog.read_body_error", + "translation": "Encountered an error reading response body from interactive dialog submission." + }, { "id": "app.system.complete_onboarding_request.app_error", "translation": "Failed to decode the complete onboarding request."