From a7d1f80ed7b5fb68b405840a3094d1fe9720a715 Mon Sep 17 00:00:00 2001 From: Yeuoly Date: Mon, 16 Dec 2024 21:04:58 +0800 Subject: [PATCH] fix: nil pointer dereference of session backwards invocation --- .../backwards_invocation/transaction/aws_event_handler.go | 5 +++++ internal/core/session_manager/session.go | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/internal/core/plugin_daemon/backwards_invocation/transaction/aws_event_handler.go b/internal/core/plugin_daemon/backwards_invocation/transaction/aws_event_handler.go index 83edf00..831cb82 100644 --- a/internal/core/plugin_daemon/backwards_invocation/transaction/aws_event_handler.go +++ b/internal/core/plugin_daemon/backwards_invocation/transaction/aws_event_handler.go @@ -8,6 +8,7 @@ import ( "github.com/gin-gonic/gin" "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_daemon/backwards_invocation" + "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager" "github.com/langgenius/dify-plugin-daemon/internal/core/session_manager" "github.com/langgenius/dify-plugin-daemon/internal/types/entities/plugin_entities" "github.com/langgenius/dify-plugin-daemon/internal/utils/log" @@ -92,6 +93,10 @@ func (h *AWSTransactionHandler) Handle( return } + // bind the backwards invocation + plugin_manager := plugin_manager.Manager() + session.BindBackwardsInvocation(plugin_manager.BackwardsInvocation()) + awsResponseWriter := NewAWSTransactionWriter(session, writer) if err := backwards_invocation.InvokeDify( diff --git a/internal/core/session_manager/session.go b/internal/core/session_manager/session.go index 8e453c1..a7adac0 100644 --- a/internal/core/session_manager/session.go +++ b/internal/core/session_manager/session.go @@ -150,6 +150,10 @@ func (s *Session) Runtime() plugin_entities.PluginLifetime { return s.runtime } +func (s *Session) BindBackwardsInvocation(backwardsInvocation dify_invocation.BackwardsInvocation) { + s.backwardsInvocation = backwardsInvocation +} + func (s *Session) BackwardsInvocation() dify_invocation.BackwardsInvocation { return s.backwardsInvocation }