Coder Social home page Coder Social logo

falafel's People

Contributors

adamtarrant avatar adriantoine avatar akirakianna avatar alirussell avatar chrisjhoughton avatar dependabot[bot] avatar edinabolkeny avatar elliot-ball-tray avatar gnyani-trayio avatar johnbastian avatar johnbastian-trayio avatar katehickey26 avatar mone avatar piotrtrzpil avatar thomaschaplin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

falafel's Issues

Add a "help" parameter to connectors

We now have a help parameter attached to connectors. As such, we can now start to build up special content and helpful links for all connectors.

Suggestion: add a help.md file on the connector level. The contents of this will get set to the help property in the connectors.json.

test

 Luka

graegraegre

 Problem overview

htshtht

Idea: automatic date formatting

Different systems have different date formats. Example:

  • Salesforce: 2016-02-18T21:54:33.000+0000
  • Zendesk: 2016-02-18T21:54:33Z

Zendesk actually rejects dates that are in the Salesforce format - causing an error in the workflow. The data needs to be formatted in a JavaScript step to be able to pass a date to Zendesk correctly.

Proposal:

  • Add a "date" format to the connectors json
  • Add a "date_format" key to schema properties to indicate the format a date should have
    The connector should automatically try and convert the date to the desired format

Why?

  • Simpler and more reliable for users!

Validation

Invalid connectors = bad. We should run programmatic validation wherever possible to minimise errors and time wasted.

Improving file handling

Current situation

Currently falafel supports file uploads and downloads, like so:

"Download" attachment

Downloads an attachment from a third party service, e.g. Salesforce, and saves it to S3. The flow is:

Get file contents > Store in memory (buffer) > Upload to S3

"Upload" attachment

Uploads an attachment to a third party service, e.g. Asana. The flow is:

Download file from S3 URL > Store in memory (buffer) > Upload to service

Key issue

Files are stored in memory. For an 8MB zip file, a 1.5GB lambda function ran out of memory while executing. No idea why, but it looks like an exponential effect.

New approach

Use the filesystem to store the files temporarily in the connector Lambda filesystem, rather than memory. This approach has already been tested and working on production with the Salesforce connector - it's at least an order of magnitude more efficient, and unlikely to be exponential.

One of the key advantages here is that we can make use of Node.js streams, which allow the data to be passed along as it is output & read, rather than having to store everything in memory first and then send it all at once.

Downloads

The flow will now be:

Get file contents > Output directly to temp file > Upload file to S3

Uploads

The flow will now be:

Download file from S3 > Output to temp file > Upload file to service


Implementation

Add a fileHandler parameter to models

Both of the above flows require a temporary file to be created and read from on the local filesystem.

Lambda allows the user to write to the local filesystem in the /tmp folder, and falafel models already allow the outputting to a file (for downloads) with the following options:

options: {
  output: '{{temp_file}}'
}

Similarly for uploads, the S3 file needs to be downloaded to a temporary file on the filesystem, so a temp_file will also be needed.

Proposal: add a new fileHandler: true option to models, to be specified on any download or upload operations.

The above will cause an additional temp_file input parameter to be added to the incoming message from the Cluster Service, in the format /tmp/guid.

The connector can then use this parameter to download & upload from, without having to go into the detail of adding this parameter itself.

File upload API change

Backwards compatibility is important here.

Upload

falafel.files.upload - currently takes the following input:

{
  name: 'my-file-name.pdf',
  contents: Buffer(....)
}

New versions should take:

{
  name: 'my-file-name.pdf',
  file: '{{temp_file}}'
}

Download

falafel.files.download - the input won't change here, but the output will. It currently outputs:

{
  contents: Buffer(...),
  name: 'my-file-name.pdf',
  mime_type: 'application/pdf',
  expires: 124513421321
}

New versions should output:

{
  file: '{{temp_file}}',
  name: 'my-file-name.pdf',
  mime_type: 'application/pdf',
  expires: 124513421321
}

Add a "getErrorMessage" method, or similar

Every API is different about how it throws back errors. It's quite important that we show a useful message to the user, rather than "Bad request" or "Invalid status code".

We need a JS function on the global level which automatically tries to pull out errors from the body on failure.

Add ability to order operations

Probably the simplest way to do this is to add a order integer value on the schema which determines the priority the operation should have. Lowest goes first.

Idea: auto typecast properties to the their correct types

Let's say someone passes a string to a connector, but it should be a number. However, it's a numeric string. The third party API might error unless the type is a pure number.

Wouldn't it be smart if we automatically typecasted the parameter to a number? It'd boost the reliability of connectors significantly.

Idea: Guarding the apptalk message format

Guard the message format to never return invalid json structure (for example a "body" that is not a json object), and return an error message in such cases. "Invalid API response, expected json object"

Don't return the original input when there is a message error

Falafel is returning the whole connector/operation input object when there is an error of any sort, which often includes sensitive information such as access tokens. The returned payload gets stored in the step output by the cluster service which is not obfuscated in any way.

Need to remove the input object from the returned payload on errors

Add a dev system to accept trigger messages and pipe them into _request messages

Sniper intercepts webhook triggers and maps them into a format that goes to the connector.

Currently if you want to test trigger connectors end-to-end offline then you can't with ngrok. It'd be great if you could.

Seems like this basically needs a proxy system in dev mode to route data to the connector in the same way sniper does.

Auto-handle some more error status codes

For a lot of error types, we respond with "Invalid status code", which isn't at all helpful for the user. We already respond with "Not found" for 404, for example - what else could we make simpler here?

Definitely handle:

  • 429 - rate limits

See http://www.restapitutorial.com/httpstatuscodes.html

These are actually handled in threadneedle (rather than falafel) here https://github.com/trayio/threadneedle/blob/master/lib/addMethod/validateExpects.js#L72

Note that you'll need unit tests for anything you add too https://github.com/trayio/threadneedle/blob/master/tests/validateExpects_test.js#L38

First step - I'd recommend putting together a list of status codes we should handle, and the error message for each. (Note that for many of the 5xx errors, we might want to use the same error message)

Chris

markdown works

Every single

time

Improve error messages for invalid files

See this error I get when trying to deploy a connector to staging:

image

It says there's an error, but doesn't provide any context as to where it's coming from. Would be useful if it did!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.