You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the body of a webhook request has a naked array, then other information in the request is not included in the outbound message.
Steps to reproduce
Create a flow of the following form. Publish and start this flow.
Webhook to code component
No Auth for the webhook component
Use {} as sample data for both components.
Use the following code for code component:
// Please note only Node.js code is supported here
async function run(msg, cfg, snapshot) {
this.logger.info('Incoming message is %s', JSON.stringify(msg));
const body = { result : 'Hello world!' };
// You can emit as many data messages as required
await this.emit('data', { body });
this.logger.info('Execution finished');
}
Send a POST request with a JSON body of the following two forms and observe the data that is logged by the code component.
Bug Report
Description
When the body of a webhook request has a naked array, then other information in the request is not included in the outbound message.
Steps to reproduce
{}
as sample data for both components.{"foo":"bar"}
[{"foo":"bar"}]
Actual result
Object Case
``` { "id": "3b69ae10-832d-11ea-9e1e-dd9d4ea250fb", "attachments": {}, "body": { "foo": "bar", "_query": {}, "_headers": { "host": "in.elastic.io", "x-request-id": "6b26ff54e5f7ad104c7a59e8f97be954", "x-real-ip": "76.64.72.41", "x-forwarded-for": "76.64.72.41", "x-forwarded-host": "in.elastic.io", "x-forwarded-port": "443", "x-forwarded-proto": "https", "x-original-uri": "/hook/5e9dc879923c3668e3160de8", "x-scheme": "https", "content-length": "17", "content-type": "application/json", "user-agent": "PostmanRuntime/7.24.1", "accept": "*/*", "cache-control": "no-cache", "postman-token": "e8757d6f-1f45-4482-aa04-9a1176a142a8", "accept-encoding": "gzip, deflate, br" }, "_method": "POST", "_url": "/hook/5e9dc879923c3668e3160de8" }, "headers": { "host": "in.elastic.io", "x-request-id": "6b26ff54e5f7ad104c7a59e8f97be954", "x-real-ip": "76.64.72.41", "x-forwarded-for": "76.64.72.41", "x-forwarded-host": "in.elastic.io", "x-forwarded-port": "443", "x-forwarded-proto": "https", "x-original-uri": "/hook/5e9dc879923c3668e3160de8", "x-scheme": "https", "content-length": "17", "content-type": "application/json", "user-agent": "PostmanRuntime/7.24.1", "accept": "*/*", "cache-control": "no-cache", "postman-token": "e8757d6f-1f45-4482-aa04-9a1176a142a8", "accept-encoding": "gzip, deflate, br" }, "metadata": {}, "url": "/hook/5e9dc879923c3668e3160de8", "method": "POST", "originalUrl": "/hook/5e9dc879923c3668e3160de8", "query": {}, "params": {}, "pathSuffix": "/hook/5e9dc879923c3668e3160de8", "taskId": "5e9dc879923c3668e3160de8", "passthrough": { "step_1": { "id": "3b69ae10-832d-11ea-9e1e-dd9d4ea250fb", "attachments": {}, "body": { "foo": "bar", "_query": {}, "_headers": { "host": "in.elastic.io", "x-request-id": "6b26ff54e5f7ad104c7a59e8f97be954", "x-real-ip": "76.64.72.41", "x-forwarded-for": "76.64.72.41", "x-forwarded-host": "in.elastic.io", "x-forwarded-port": "443", "x-forwarded-proto": "https", "x-original-uri": "/hook/5e9dc879923c3668e3160de8", "x-scheme": "https", "content-length": "17", "content-type": "application/json", "user-agent": "PostmanRuntime/7.24.1", "accept": "*/*", "cache-control": "no-cache", "postman-token": "e8757d6f-1f45-4482-aa04-9a1176a142a8", "accept-encoding": "gzip, deflate, br" }, "_method": "POST", "_url": "/hook/5e9dc879923c3668e3160de8" }, "headers": { "host": "in.elastic.io", "x-request-id": "6b26ff54e5f7ad104c7a59e8f97be954", "x-real-ip": "76.64.72.41", "x-forwarded-for": "76.64.72.41", "x-forwarded-host": "in.elastic.io", "x-forwarded-port": "443", "x-forwarded-proto": "https", "x-original-uri": "/hook/5e9dc879923c3668e3160de8", "x-scheme": "https", "content-length": "17", "content-type": "application/json", "user-agent": "PostmanRuntime/7.24.1", "accept": "*/*", "cache-control": "no-cache", "postman-token": "e8757d6f-1f45-4482-aa04-9a1176a142a8", "accept-encoding": "gzip, deflate, br" }, "metadata": {}, "url": "/hook/5e9dc879923c3668e3160de8", "method": "POST", "originalUrl": "/hook/5e9dc879923c3668e3160de8", "query": {}, "params": {}, "pathSuffix": "/hook/5e9dc879923c3668e3160de8", "taskId": "5e9dc879923c3668e3160de8" } } } ```Array Case
``` { "id": "65089880-833c-11ea-9e1e-dd9d4ea250fb", "attachments": {}, "body": [ { "foo": "bar" } ], "headers": { "host": "in.elastic.io", "x-request-id": "dabf832f68a8297957a4c3a841357253", "x-real-ip": "76.64.72.41", "x-forwarded-for": "76.64.72.41", "x-forwarded-host": "in.elastic.io", "x-forwarded-port": "443", "x-forwarded-proto": "https", "x-original-uri": "/hook/5e9dc879923c3668e3160de8", "x-scheme": "https", "content-length": "19", "content-type": "application/json", "user-agent": "PostmanRuntime/7.24.1", "accept": "*/*", "cache-control": "no-cache", "postman-token": "6e4220f2-3e54-4957-9809-d55b0e586988", "accept-encoding": "gzip, deflate, br" }, "metadata": {}, "url": "/hook/5e9dc879923c3668e3160de8", "method": "POST", "originalUrl": "/hook/5e9dc879923c3668e3160de8", "query": {}, "params": {}, "pathSuffix": "/hook/5e9dc879923c3668e3160de8", "taskId": "5e9dc879923c3668e3160de8", "passthrough": { "step_1": { "id": "65089880-833c-11ea-9e1e-dd9d4ea250fb", "attachments": {}, "body": [ { "foo": "bar" } ], "headers": { "host": "in.elastic.io", "x-request-id": "dabf832f68a8297957a4c3a841357253", "x-real-ip": "76.64.72.41", "x-forwarded-for": "76.64.72.41", "x-forwarded-host": "in.elastic.io", "x-forwarded-port": "443", "x-forwarded-proto": "https", "x-original-uri": "/hook/5e9dc879923c3668e3160de8", "x-scheme": "https", "content-length": "19", "content-type": "application/json", "user-agent": "PostmanRuntime/7.24.1", "accept": "*/*", "cache-control": "no-cache", "postman-token": "6e4220f2-3e54-4957-9809-d55b0e586988", "accept-encoding": "gzip, deflate, br" }, "metadata": {}, "url": "/hook/5e9dc879923c3668e3160de8", "method": "POST", "originalUrl": "/hook/5e9dc879923c3668e3160de8", "query": {}, "params": {}, "pathSuffix": "/hook/5e9dc879923c3668e3160de8", "taskId": "5e9dc879923c3668e3160de8" } } } ```Observe the presence of the following fields that are present in the body of the message for the object case but not the array case:
_url
_method
_headers
_query
Expected results
It is possible to read URL, Method, Headers and Query from the body of the message even if the request body is an array.
Proposed Solution
Create a new (backwards incompatible) receive method and depricate the existing method. The message structure of the body of the new method should be:
The text was updated successfully, but these errors were encountered: