Skip to content

fix: /projects endpoint returning null instead of empty array #140

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 9, 2022
Merged
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
Get tests green
  • Loading branch information
bryphe-coder committed Feb 2, 2022
commit 7ec0abc8fc5e61e7cb8242da7084599156a8fa57
2 changes: 2 additions & 0 deletions coderd/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func (api *api) projects(rw http.ResponseWriter, r *http.Request) {
projects, err := api.Database.GetProjectsByOrganizationIDs(r.Context(), organizationIDs)
if errors.Is(err, sql.ErrNoRows) {
err = nil
projects = []database.Project{}
}
if err != nil {
httpapi.Write(rw, http.StatusInternalServerError, httpapi.Response{
Expand All @@ -59,6 +60,7 @@ func (api *api) projectsByOrganization(rw http.ResponseWriter, r *http.Request)
projects, err := api.Database.GetProjectsByOrganizationIDs(r.Context(), []string{organization.ID})
if errors.Is(err, sql.ErrNoRows) {
err = nil
projects = []database.Project{}
}
if err != nil {
httpapi.Write(rw, http.StatusInternalServerError, httpapi.Response{
Expand Down