fix: remove LogError call that triggered nil pointer in /ai new
This commit is contained in:
+12
-4
@@ -33,7 +33,16 @@ Also works with /ai <prompt>. /ai new clears memory.
|
||||
func (p *Plugin) ExecuteCommand(_ *plugin.Context, args *model.CommandArgs) (resp *model.CommandResponse, err *model.AppError) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
p.API.LogError("ExecuteCommand panic", "recover", fmt.Sprintf("%v", r))
|
||||
p.API.LogError("ExecuteCommand panic",
|
||||
"recover", fmt.Sprintf("%v", r),
|
||||
"p_is_nil", fmt.Sprintf("%v", p == nil),
|
||||
"api_nil", fmt.Sprintf("%v", p != nil && p.API == nil),
|
||||
"store_nil", fmt.Sprintf("%v", p != nil && p.conversationStore == nil),
|
||||
"engine_nil", fmt.Sprintf("%v", p != nil && p.engagementEngine == nil),
|
||||
"rate_nil", fmt.Sprintf("%v", p != nil && p.rateLimiter == nil),
|
||||
"config_nil", fmt.Sprintf("%v", p != nil && p.configuration == nil),
|
||||
"args_nil", fmt.Sprintf("%v", args == nil),
|
||||
)
|
||||
resp = &model.CommandResponse{
|
||||
ResponseType: model.CommandResponseTypeEphemeral,
|
||||
Text: "Command failed due to an internal error. Check server logs for details.",
|
||||
@@ -50,10 +59,9 @@ func (p *Plugin) ExecuteCommand(_ *plugin.Context, args *model.CommandArgs) (res
|
||||
return p.response(helpText), nil
|
||||
|
||||
case parts[0] == "new":
|
||||
p.API.LogInfo("Debug /ai new", "store_nil", p.conversationStore == nil, "engine_nil", p.engagementEngine == nil)
|
||||
if p.conversationStore != nil {
|
||||
if err := p.conversationStore.Reset(args.UserId, args.ChannelId); err != nil {
|
||||
p.API.LogError("Failed to reset conversation", "error", err.Error())
|
||||
}
|
||||
p.conversationStore.Reset(args.UserId, args.ChannelId)
|
||||
}
|
||||
if p.engagementEngine != nil {
|
||||
p.engagementEngine.Sleep(args.UserId, args.ChannelId)
|
||||
|
||||
Reference in New Issue
Block a user