Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: return the created workspace
  • Loading branch information
DanielleMaywood committed Aug 29, 2025
commit dfe4055f04d5cd8f72cc123c2276e3bea633a731
4 changes: 3 additions & 1 deletion coderd/aitasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,12 @@ func (api *API) tasksCreate(rw http.ResponseWriter, r *http.Request) {
})

defer commitAudit()
_, err = createWorkspace(ctx, aReq, apiKey.UserID, api, owner, createReq, r)
w, err := createWorkspace(ctx, aReq, apiKey.UserID, api, owner, createReq, r)
if err != nil {
httperror.WriteResponseError(ctx, rw, err)
}

httpapi.Write(ctx, rw, http.StatusCreated, w)
}

// tasksFromWorkspaces converts a slice of API workspaces into tasks, fetching
Expand Down
4 changes: 1 addition & 3 deletions coderd/httpapi/httperror/responserror.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,4 @@ func (e *responseError) Response() (int, codersdk.Response) {
return e.status, e.response
}

var (
ErrResourceNotFound = NewResponseError(http.StatusNotFound, httpapi.ResourceNotFoundResponse)
)
var ErrResourceNotFound = NewResponseError(http.StatusNotFound, httpapi.ResourceNotFoundResponse)
9 changes: 7 additions & 2 deletions coderd/workspaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,10 +388,12 @@ func (api *API) postWorkspacesByOrganization(rw http.ResponseWriter, r *http.Req
AvatarURL: member.AvatarURL,
}

_, err := createWorkspace(ctx, aReq, apiKey.UserID, api, owner, req, r)
w, err := createWorkspace(ctx, aReq, apiKey.UserID, api, owner, req, r)
if err != nil {
httperror.WriteResponseError(ctx, rw, err)
}

httpapi.Write(ctx, rw, http.StatusCreated, w)
}

// Create a new workspace for the currently authenticated user.
Expand Down Expand Up @@ -481,10 +483,13 @@ func (api *API) postUserWorkspaces(rw http.ResponseWriter, r *http.Request) {

defer commitAudit()

_, err := createWorkspace(ctx, aReq, apiKey.UserID, api, owner, req, r)
w, err := createWorkspace(ctx, aReq, apiKey.UserID, api, owner, req, r)
if err != nil {
httperror.WriteResponseError(ctx, rw, err)
return
}

httpapi.Write(ctx, rw, http.StatusCreated, w)
}

type workspaceOwner struct {
Expand Down
Loading