diff --git a/server/channels/app/command.go b/server/channels/app/command.go index fcb25138fb1..5ffbd4988db 100644 --- a/server/channels/app/command.go +++ b/server/channels/app/command.go @@ -672,8 +672,6 @@ func (a *App) HandleCommandResponsePost(rctx request.CTX, command *model.Command } else if response.IconURL != "" { post.AddProp(model.PostPropsOverrideIconURL, response.IconURL) isBotPost = true - } else { - post.AddProp(model.PostPropsOverrideIconURL, "") } } diff --git a/server/channels/app/slashcommands/command_test.go b/server/channels/app/slashcommands/command_test.go index bac1efcaaac..32bb159f9d8 100644 --- a/server/channels/app/slashcommands/command_test.go +++ b/server/channels/app/slashcommands/command_test.go @@ -250,6 +250,17 @@ func TestHandleCommandResponsePost(t *testing.T) { assert.Equal(t, resp.IconURL, post.GetProp(model.PostPropsOverrideIconURL)) assert.Equal(t, "true", post.GetProp(model.PostPropsFromWebhook)) + resp.IconURL = "" + + // When both command and response icon URLs are empty and EnablePostIconOverride is enabled, + // override_icon_url must not be set (avoids spurious "prop must be a valid URL" warning). + post, err = th.App.HandleCommandResponsePost(th.Context, command, args, resp, builtIn) + assert.Nil(t, err) + assert.Nil(t, post.GetProp(model.PostPropsOverrideIconURL)) + assert.NotContains(t, post.GetProps(), model.PostPropsOverrideIconURL) + + resp.IconURL = "Response icon url" + // Test Slack text conversion. resp.Text = ""