Skip to content

Commit ccc2ea4

Browse files
committed
fix: send the correct payload when creating workspaces from workspaces
The workspace-provider daemon expects fromWorkspaceIDs instead of workspace_ids. Signed-off-by: Donnie Adams <[email protected]>
1 parent f8b95c9 commit ccc2ea4

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

pkg/sdkserver/workspaces.go

+10-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"encoding/json"
55
"fmt"
66
"net/http"
7-
"strings"
87

98
gcontext "github.com/gptscript-ai/gptscript/pkg/context"
109
"github.com/gptscript-ai/gptscript/pkg/loader"
@@ -52,14 +51,20 @@ func (s *server) createWorkspace(w http.ResponseWriter, r *http.Request) {
5251
reqObject.ProviderType = "directory"
5352
}
5453

54+
b, err := json.Marshal(map[string]any{
55+
"provider": reqObject.ProviderType,
56+
"fromWorkspaceIDs": reqObject.FromWorkspaceIDs,
57+
})
58+
if err != nil {
59+
writeError(logger, w, http.StatusInternalServerError, fmt.Errorf("failed to marshal request body: %w", err))
60+
return
61+
}
62+
5563
out, err := s.client.Run(
5664
r.Context(),
5765
prg,
5866
s.getServerToolsEnv(reqObject.Env),
59-
fmt.Sprintf(
60-
`{"provider": "%s", "workspace_ids": "%s"}`,
61-
reqObject.ProviderType, strings.Join(reqObject.FromWorkspaceIDs, ","),
62-
),
67+
string(b),
6368
)
6469
if err != nil {
6570
writeError(logger, w, http.StatusInternalServerError, fmt.Errorf("failed to run program: %w", err))

0 commit comments

Comments
 (0)