Comment 4 for bug 1409109

Revision history for this message
Gilbert Pilz (gilbert.pilz) wrote : Re: [Bug 1409109] Re: API responds with incorrect Content-Type on HTTP errors

@devdatta:

It's been a while since I looked at this code but, if I remember correctly, it is the methods on any resource that uses just the @pecan.expose annotations and not the @wsme_pecan.expose annotations. I forget exactly why some resources needed to do this - except I remember the WSME made it hard/impossible to do some things.

~ gp

On Nov 2, 2015, at 2:02 PM, Devdatta Kulkarni <email address hidden> wrote:

> @gilbert.pilz:
>
> I was wondering if you could point out which methods on which resources
> are only returning plain text?
>
> It will be good to have this list to enable us to fix it.
>
> Devdatta
>
> ** Tags added: solum-api
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1409109
>
> Title:
> API responds with incorrect Content-Type on HTTP errors
>
> Status in Solum:
> Triaged
>
> Bug description:
> Solum resources that are exposed with "@pecan.expose" (not sure about
> those exposed by "@wsme_pecan.expose()") have an incorrect Content-
> Type value when the response is an HTTP error. For example, the
> response body might be something like "Plan is invalid ..." but the
> value of the Content-Type header will be "application/x-yaml" when it
> should be "text/plain". This causes problems for client side tooling
> (like tempest) that attempts to interpret the response body based on
> the value of the Content-Type header.
>
> The reason for this is that our common exception handling code
> (enabled by "@exception.wrap_pecan_controller_exception") attempts to
> manually set the correct 'content_type' value (1), but this value is
> later overwritten by the pecan framework code (2). The correct
> mechanism to set a Content-Type that is different from the expected
> Content-Type is to override the declared controller template using the
> "pecan.override_template()" (3) method.
>
> 1.)
> https://github.com/stackforge/solum/blob/master/solum/common/exception.py#L154
>
> 2.) https://github.com/stackforge/pecan/blob/master/pecan/core.py#L601
>
> 3.) https://pecan.readthedocs.org/en/latest/pecan_core.html
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/solum/+bug/1409109/+subscriptions