Skip to content

Commit 955df58

Browse files
committed
Revert "feat: install plugin api add optional current task response"
This reverts commit bf16b52.
1 parent bf16b52 commit 955df58

3 files changed

Lines changed: 18 additions & 77 deletions

File tree

internal/service/install_plugin.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ import (
2727
)
2828

2929
type InstallPluginResponse struct {
30-
AllInstalled bool `json:"all_installed"`
31-
TaskID string `json:"task_id"`
32-
Task *models.InstallTask `json:"task,omitempty"`
30+
AllInstalled bool `json:"all_installed"`
31+
TaskID string `json:"task_id"`
3332
}
3433

3534
// Dify supports install multiple plugins to a tenant at once
@@ -143,7 +142,6 @@ func InstallMultiplePluginsToTenant(
143142
// EE edition reference task should not be the first one
144143
// here we use `PrimaryID` to present the user-facing task id
145144
TaskID: taskRegistry.PrimaryID(),
146-
Task: taskRegistry.PrimaryTask(),
147145
})
148146
}
149147

@@ -320,7 +318,6 @@ func UpgradePlugin(
320318
return entities.NewSuccessResponse(&InstallPluginResponse{
321319
AllInstalled: false,
322320
TaskID: taskRegistry.PrimaryID(),
323-
Task: taskRegistry.PrimaryTask(),
324321
})
325322
}
326323

internal/service/install_plugin_test.go

Lines changed: 13 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -5,57 +5,9 @@ import (
55
"testing"
66

77
"github.com/langgenius/dify-plugin-daemon/internal/types/app"
8-
"github.com/langgenius/dify-plugin-daemon/internal/types/models"
98
"github.com/langgenius/dify-plugin-daemon/pkg/entities/plugin_entities"
109
)
1110

12-
func TestInstallPluginResponseIncludesPrimaryTask(t *testing.T) {
13-
setupTestDB(t)
14-
15-
identifier, err := plugin_entities.NewPluginUniqueIdentifier("author/test-plugin:1.0.0@abcdef1234567890abcdef1234567890ab")
16-
if err != nil {
17-
t.Fatalf("failed to create plugin unique identifier: %v", err)
18-
}
19-
20-
taskRegistry, err := createInstallTasks([]string{"tenant-123"}, []models.InstallTaskPluginStatus{
21-
{
22-
PluginUniqueIdentifier: identifier,
23-
PluginID: identifier.PluginID(),
24-
Status: models.InstallTaskStatusPending,
25-
Source: "marketplace",
26-
},
27-
})
28-
if err != nil {
29-
t.Fatalf("failed to create install task: %v", err)
30-
}
31-
32-
response := InstallPluginResponse{
33-
AllInstalled: false,
34-
TaskID: taskRegistry.PrimaryID(),
35-
Task: taskRegistry.PrimaryTask(),
36-
}
37-
38-
data, err := json.Marshal(response)
39-
if err != nil {
40-
t.Fatalf("failed to marshal response: %v", err)
41-
}
42-
43-
var decoded InstallPluginResponse
44-
if err := json.Unmarshal(data, &decoded); err != nil {
45-
t.Fatalf("failed to unmarshal response: %v", err)
46-
}
47-
48-
if decoded.Task == nil {
49-
t.Fatal("expected response task to be present")
50-
}
51-
if decoded.TaskID == "" {
52-
t.Fatal("expected response task_id to be present")
53-
}
54-
if decoded.Task.ID != decoded.TaskID {
55-
t.Fatalf("task id mismatch: got %s, want %s", decoded.Task.ID, decoded.TaskID)
56-
}
57-
}
58-
5911
func TestUpgradePlugin(t *testing.T) {
6012
originalIdentifier, err := plugin_entities.NewPluginUniqueIdentifier("author/test-plugin:1.0.0@abcdef1234567890abcdef1234567890ab")
6113
if err != nil {
@@ -72,32 +24,32 @@ func TestUpgradePlugin(t *testing.T) {
7224
}
7325

7426
tests := []struct {
75-
name string
76-
tenantId string
77-
source string
78-
meta map[string]any
79-
originalPluginUniqueIdentifier plugin_entities.PluginUniqueIdentifier
80-
newPluginUniqueIdentifier plugin_entities.PluginUniqueIdentifier
81-
wantSuccess bool
82-
wantAllInstalled bool
83-
wantTaskIDEmpty bool
27+
name string
28+
tenantId string
29+
source string
30+
meta map[string]any
31+
originalPluginUniqueIdentifier plugin_entities.PluginUniqueIdentifier
32+
newPluginUniqueIdentifier plugin_entities.PluginUniqueIdentifier
33+
wantSuccess bool
34+
wantAllInstalled bool
35+
wantTaskIDEmpty bool
8436
}{
8537
{
8638
name: "same plugin identifiers",
8739
tenantId: "tenant-123",
8840
source: "test",
8941
meta: map[string]any{},
90-
originalPluginUniqueIdentifier: originalIdentifier,
91-
newPluginUniqueIdentifier: originalIdentifier,
42+
originalPluginUniqueIdentifier: originalIdentifier,
43+
newPluginUniqueIdentifier: originalIdentifier,
9244
wantSuccess: false,
9345
},
9446
{
9547
name: "different plugin identifiers",
9648
tenantId: "tenant-123",
9749
source: "test",
9850
meta: map[string]any{},
99-
originalPluginUniqueIdentifier: originalIdentifier,
100-
newPluginUniqueIdentifier: newIdentifier,
51+
originalPluginUniqueIdentifier: originalIdentifier,
52+
newPluginUniqueIdentifier: newIdentifier,
10153
wantSuccess: false,
10254
},
10355
}

internal/tasks/install_plugin_utils.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,13 @@ func (r *InstallTaskRegistry) IDs() []string {
2929
}
3030

3131
func (r *InstallTaskRegistry) PrimaryID() string {
32-
task := r.PrimaryTask()
33-
if task == nil {
34-
return ""
35-
}
36-
return task.ID
37-
}
38-
39-
func (r *InstallTaskRegistry) PrimaryTask() *models.InstallTask {
4032
if len(r.Order) == 0 {
41-
return nil
33+
return ""
4234
}
4335
if task, ok := r.Tasks[r.Order[0]]; ok {
44-
return task
36+
return task.ID
4537
}
46-
return nil
38+
return ""
4739
}
4840

4941
func truncateMessage(message string) string {

0 commit comments

Comments
 (0)