RedHatInsights / insights-api-common-rails

Header, Encryption, RBAC, Serialization, Pagination and other common behavior for Insights microservices built with Rails
Apache License 2.0
3 stars 25 forks source link

HTTP errors are not properly translated to status in error doc #178

Closed mkanoor closed 4 years ago

mkanoor commented 4 years ago

Below is an example of an error document where the status is not converted to integer and comes out as the string value of the RAILS http symbol.

{
    "errors": [
        {
            "status": "bad_request",
            "detail": "Exceptions::UserError: Group ba403c79-14bb-4a1e-a65c-31ff711d9cfd does not exist"
        },
        {
            "status": 404,
            "detail": "RBACApiClient::ApiError: Error message: the server returns an error\nHTTP status code: 404\nResponse headers: {\"x-powered-by\"=>\"Express\", \"x-fakamai-env\"=>\"ci\", \"x-fakamai-app-hint\"=>\"API\", \"x-fakamai-downstream-host\"=>\"https://api-gateway-ci.5a9f.insights-dev.openshiftapps.com\", \"server\"=>\"openresty/1.13.6.1\", \"date\"=>\"Mon, 13 Apr 2020 17:51:06 GMT\", \"content-type\"=>\"application/json\", \"x-rh-insights-request-id\"=>\"fd74f806f64c4e60a89d00b3d5152750\", \"vary\"=>\"Accept, Origin\", \"allow\"=>\"GET, PUT, PATCH, DELETE, HEAD, OPTIONS\", \"x-frame-options\"=>\"SAMEORIGIN\", \"x-content-type-options\"=>\"nosniff\", \"set-cookie\"=>\"bd2e829019cc5851647126f4f0834941=5040a645e9d4912b5513f4d2f9664fd7; path=/; HttpOnly; Secure\", \"cache-control\"=>\"private\"}\nResponse body: {\"errors\":[{\"detail\":\"Not found.\",\"source\":\"detail\",\"status\":404}]}"
        }
    ]
}