It's not possible to use either the "customError" or "custom" method containing a response code >= 400 <= 600 together with a custom payload. The only property available is "message" and it must contain only a string.
In essence, the "custom" methods don't actually expose full control over the reply. If the framework requires a particular shape for error payloads, is there at least some way to tap into the underlying HAPI response object to circumvent this limitation?
That's an expected behavior. Kibana server endpoints are meant to be used and consumed by the Kibana UI. On the client-side, we are doing some checks implicitly from within the 'core' platform when an error is send back from the server to the client, which is one of the reasons why we are expecting an homogeneous format for our server->client errors structure, and are enforcing it in our server-side routing API that is exposed to plugins.
The only (highly discouraged) workaround would be to use a Stream or a Buffer as the body when returning your custom error, as we are not doing any sanity check around these kind of response formats. Note that if (I think that) it would be working with our current master version, it could break at any time in the future.
Thanks for the quick reply... and BTW, cool name :). Yes the e.body.attributes is the proper solution. I forgot to mention that I had tried it before but the data was filtered. However I must have either... (a) made a typo ... or ... (b) put the attributes property in the wrong place.
In case it helps others, you can see that the Kibana platform silently filters out invalid attributes. The system will also dig into the message property and, if it's of type object, will extract a message.message string (if exists). This is approach accounts for the possibility of providing a new Error('message') (exception object) rather than just a message string.
It seems like you're not using typescript? We highly recommend that you use typescript for writing your plugin, it will make it a lot easier to integrate with the plugin API's. There are a lot of places in Kibana where we will silently ignore invalid parameters because we rely on typescript to detect this.
In your own code you can always decide to use any if you don't care about typesafety.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.