Skip to content
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

fix #540 #246

Merged
merged 3 commits into from
Jul 11, 2024
Merged
Changes from all commits
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
6 changes: 6 additions & 0 deletions index/server/pkg/server/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,12 @@ func buildIndexAPIResponse(c *gin.Context, indexType string, wantV1Index bool, p
if params.Deprecated != nil {
util.FilterDevfileDeprecated(&index, *params.Deprecated, wantV1Index)
}
if index == nil || len(index) == 0 {
c.JSON(http.StatusOK, gin.H{
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
c.JSON(http.StatusOK, gin.H{
c.JSON(http.StatusInternalServerError, gin.H{

I'm wondering if this should be a 500 instead of a 200 as it not having the samples is technically an error and is referenced as an error in the original issue

https://go.dev/src/net/http/status.go

wdyt @michael-valdron

Copy link
Member

Choose a reason for hiding this comment

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

@Jdubrick Maybe 404 would be more appropriate error code here, since no stacks or samples can be found.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking 500 as it would be the servers fault no samples were loaded, no? I am also okay with 404 though

Copy link
Member

Choose a reason for hiding this comment

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

I was thinking 500 as it would be the servers fault no samples were loaded, no? I am also okay with 404 though

That is a good point, but in this case the control logic that provides this response does not guarantee that the stacks and samples are not loaded due to error versus just having an empty registry.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm okay with 404 in that case.

@Horiodino for reference that is http.StatusNotFound

Copy link
Member

Choose a reason for hiding this comment

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

IMO, in a world where we're working towards more dynamic devfile registries, I'd argue that a 200 code is fine here.

"status": "No stacks or samples found in the registry",
})
return
}

if wantV1Index {
index = util.ConvertToOldIndexFormat(index)
Expand Down
Loading