diff --git a/internal/core/dify_invocation/real/encrypt_test.go b/internal/core/dify_invocation/real/encrypt_test.go index 7ce9b0b9..af066972 100644 --- a/internal/core/dify_invocation/real/encrypt_test.go +++ b/internal/core/dify_invocation/real/encrypt_test.go @@ -76,7 +76,9 @@ func TestInvokeEncrypt(t *testing.T) { http_invoked = true ctx.JSON(http.StatusOK, gin.H{ - "key": "encrypted", + "data": map[string]any{ + "key": "encrypted", + }, }) }) diff --git a/internal/core/dify_invocation/real/http_request.go b/internal/core/dify_invocation/real/http_request.go index e2be348e..47de15fd 100644 --- a/internal/core/dify_invocation/real/http_request.go +++ b/internal/core/dify_invocation/real/http_request.go @@ -11,6 +11,7 @@ import ( "github.com/langgenius/dify-plugin-daemon/internal/utils/stream" ) +// Send a request to dify inner api and validate the response func Request[T any](i *RealBackwardsInvocation, method string, path string, options ...http_requests.HttpOptions) (*T, error) { options = append(options, http_requests.HttpHeader(map[string]string{ @@ -89,10 +90,10 @@ func (i *RealBackwardsInvocation) InvokeEncrypt(payload *dify_invocation.InvokeE return payload.Data, nil } - data, err := Request[map[string]any](i, "POST", "invoke/encrypt", http_requests.HttpPayloadJson(payload)) + data, err := Request[dify_invocation.InvokeEncryptionResponse](i, "POST", "invoke/encrypt", http_requests.HttpPayloadJson(payload)) if err != nil { return nil, err } - return *data, nil + return data.Data, nil } diff --git a/internal/core/dify_invocation/types.go b/internal/core/dify_invocation/types.go index 330b26c8..a54b0fc8 100644 --- a/internal/core/dify_invocation/types.go +++ b/internal/core/dify_invocation/types.go @@ -212,3 +212,8 @@ type InvokeNodeResponse struct { Outputs map[string]any `json:"outputs" validate:"required"` Inputs map[string]any `json:"inputs" validate:"required"` } + +type InvokeEncryptionResponse struct { + Error string `json:"error"` + Data map[string]any `json:"data" validate:"required"` +}