- Notifications
You must be signed in to change notification settings - Fork1.1k
feat: added include_deleted to getWorkspaceByOwnerAndName#2164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
142ad4e5c77ea431f40139389df3769ea99f8a844c56bceb6ee1f41728c2db65381554File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -83,6 +83,7 @@ | ||
| "workspaceapp", | ||
| "workspaceapps", | ||
| "workspacebuilds", | ||
| "workspacename", | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. 👍 | ||
| "wsconncache", | ||
| "xerrors", | ||
| "xstate", | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -165,10 +165,32 @@ func (api *API) workspaceByOwnerAndName(rw http.ResponseWriter, r *http.Request) | ||||||||||||||
| owner := httpmw.UserParam(r) | ||||||||||||||
| workspaceName := chi.URLParam(r, "workspacename") | ||||||||||||||
| includeDeleted := false | ||||||||||||||
| if s := r.URL.Query().Get("include_deleted"); s != "" { | ||||||||||||||
| var err error | ||||||||||||||
| includeDeleted, err = strconv.ParseBool(s) | ||||||||||||||
| if err != nil { | ||||||||||||||
| httpapi.Write(rw, http.StatusBadRequest, httpapi.Response{ | ||||||||||||||
| Message: fmt.Sprintf("Invalid boolean value %q for \"include_deleted\" query param.", s), | ||||||||||||||
| Validations: []httpapi.Error{ | ||||||||||||||
| {Field: "include_deleted", Detail: "Must be a valid boolean"}, | ||||||||||||||
| }, | ||||||||||||||
| }) | ||||||||||||||
| return | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
| workspace, err := api.Database.GetWorkspaceByOwnerIDAndName(r.Context(), database.GetWorkspaceByOwnerIDAndNameParams{ | ||||||||||||||
| OwnerID: owner.ID, | ||||||||||||||
| Name: workspaceName, | ||||||||||||||
| }) | ||||||||||||||
| if includeDeleted && errors.Is(err, sql.ErrNoRows) { | ||||||||||||||
| workspace, err = api.Database.GetWorkspaceByOwnerIDAndName(r.Context(), database.GetWorkspaceByOwnerIDAndNameParams{ | ||||||||||||||
| OwnerID: owner.ID, | ||||||||||||||
| Name: workspaceName, | ||||||||||||||
| Deleted: includeDeleted, | ||||||||||||||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I don't think this works as intended. The param here in the SQL matches for So if you set this to true, the workspace will not show if the workspace is deleted. We will need to update the SQL too, or just always return deleted workspaces by default. Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. See how it's handled here: Lines 57 to 62 in454aea7
I think the MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. @Emyrk Hmm, testing it in the UI seems to work.
In either case, if we get nothing back, we then go into the Let me know if I'm misunderstanding your comment! | ||||||||||||||
| }) | ||||||||||||||
| } | ||||||||||||||
| if errors.Is(err, sql.ErrNoRows) { | ||||||||||||||
| // Do not leak information if the workspace exists or not | ||||||||||||||
| httpapi.Forbidden(rw) | ||||||||||||||