pivotal-cf / brokerapi

A Go package for implementing the V2 Open Service Broker API
Apache License 2.0
85 stars 71 forks source link

Is the FailureResponse status code used? #162

Closed renier closed 3 years ago

renier commented 3 years ago

I ask because I have an implementation like this:

func (f *serviceBroker) Services(ctx context.Context) ([]domain.Service, error) {
    return nil, apiresponses.NewFailureResponse(errors.New("TODO"), http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) // TODO: Implement
}

but going to /v2/catalog gives me this http response:

$> curl -i -u ":" -H "X-Broker-API-Version: 2.13" http://localhost:8080/v2/catalog
HTTP/1.1 500 Internal Server Error
Content-Type: application/json
Correlation-Id: c2g7orea0bri9krepjs0
Date: Sun, 16 May 2021 01:59:09 GMT
Content-Length: 23

{"description":"TODO"}

Using v8 of this module.

Based on the docs here, I expected the response status code to be 501 instead.

renier commented 3 years ago

Yep, it's a problem specifically with the catalog handler here. It should have been coded to test for a FailureResponse error like this.

FelisiaM commented 3 years ago

Hi @renier

Thanks for catching this. Would you be open to creating a PR with the change and corresponding tests for it?

Thanks, Felisia

renier commented 3 years ago

@FelisiaM Ok. See #165

FelisiaM commented 3 years ago

Thank you for your contribution @renier!

This change will be included in the next release in a few days.