elasticio / xml-component

Component to parse, validate, generate XML data & attachments for elastic.io platform
Other
0 stars 5 forks source link

Component does not handle empty attachments correctly #34

Open jhorbulyk opened 4 years ago

jhorbulyk commented 4 years ago

Steps to reproduce

  1. Create a 3 step flow of the following form:

    • Code component with
      this input code async function run(msg, cfg, snapshot) { const urlRequest = await request({ url: 'https://api.elastic.io/v2/resources/storage/signed-url', method: 'POST', auth: { username: process.env.ELASTICIO_API_USERNAME, password: process.env.ELASTICIO_API_KEY } }); const url = JSON.parse(urlRequest.body).get_url;

    const putRequest = await request({ url, method: 'PUT' });

    this.emit('data', {body: { url }, attachments: { 'file.xml': { url } } }); }

    • XML component: XML Attachment to JSON
    • Pattern to match files: .
    • Email component: send email
    • To:
    • Subject: Test
    • Body: Test
      1. Publish the flow and run it once.

Expected Result

XML component throws an error since the attachment contains the empty string which is not valid XML.

Actual result

An error badge appears around the email component: Cannot use 'in' operator to search for 'elasticio' in null

This Sailor bug is partially to blame for the above behavior: https://github.com/elasticio/sailor-nodejs/issues/64