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
Merge main
  • Loading branch information
bryphe-coder committed Feb 9, 2022
commit f10ee4d773b3f5e5e8f26ac8d8d907e7d0bbe668
10 changes: 9 additions & 1 deletion coderd/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,11 @@ func (api *api) projects(rw http.ResponseWriter, r *http.Request) {
})
return
}
// Don't return 'null'

if projects == nil {
projects = []database.Project{}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather us to this inside the sql.ErrNoRows like before, and depend on tests to catch the incorrect behavior.

I'm worried about a developer making a mistake for something else, and this masking the error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this change is also already in main with #166 🎉

}

render.Status(r, http.StatusOK)
render.JSON(rw, r, projects)
}
Expand All @@ -79,10 +80,17 @@ func (api *api) projectsByOrganization(rw http.ResponseWriter, r *http.Request)
})
return
}
<<<<<<< HEAD
// Don't return 'null'
if projects == nil {
projects = []database.Project{}
}
||||||| 2afad8b
=======
if projects == nil {
projects = []database.Project{}
}
>>>>>>> main
render.Status(r, http.StatusOK)
render.JSON(rw, r, projects)
}
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.