zapier / zapier-platform

The SDK for you to build an integration on Zapier

Home Page:https://platform.zapier.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

zapier convert throws an error even though the UI doesn't show any

sturlath opened this issue · comments

Bug Description

I started creating my Zaps in the UI and they just work there (they can authenticate and show
no errors when validating) but now I'm trying out the CLI and I get the following error when running zapier convert 103195 . --version=1.0.0

image

All my zaps have this http header binding syntax where I can't see anything amiss..
image

My UI doesn't think there is anything wrong yes few warnings telling me to add description but no errors.

image

I hope I have given you enough information on this for you to help me out because I really would like to be able to extract what I have done in the UI into to code where I get more power.

Version Info

  • Version info: zapier-platform-cli/10.0.0 win32-x64 node-v12.16.2
  • Operating System: Windows 10
  • App id: I don't get that far because it fails. But if its the same as the "integration id" its 103195

@sturlath hey there! that's a bug in our converter, thanks for finding it. Your app in the UI and zaps aren't affected- it's just an issue when writing a test file locally.

it looks like it's only affecting that one test file - it should be {"X-API-KEY": ...

If the file is still on your computer, you can make that change manually and it'll be fine. we'll get that fixed up in the meantime though.

This issue has been copied into our private issue tracker (as PDE-1535). Thanks for the report! We'll update this as we learn more.

@xavdid the files never get created locally it seems or are they created somewhere temporarily? When do you think you will push an update because I'm also having problems with the UI.

I tried to make the x-api-key value just static but that didn't work at all. Next would be to remove my token authentication just so I could download the code and work with the CLI to get more logs/power but I will need to find that out after the weekend if having no authentication will allow me to download the code.

I would rather not have to redo all my UI "coding" in the CLI from scratch so I hope I don't have to do that..

@xavdid I managed to download the project by removing the Authentication part but now I get this, and its not telling me much...

image

searches/lookup.js

module.exports = {
  operation: {
    perform: {
      url: 'https://quicklookupapiapp.azurewebsites.net/api/batch/lookup',
      method: 'GET',
      headers: {
        'Content-Type': 'application/json',
        Accept: 'application/json',
        'X-API-KEY': '{{bundle.authData.x_api_key}}',
      },
      params: {
        lookupValue: '{{bundle.inputData.lookupValue}}',
        propertyName: '{{bundle.inputData.propertyName}}',
      },
      headers: {
        'Content-Type': 'application/json',
        Accept: 'application/json',
      },
      body: {
        lookupValue: '{{bundle.inputData.lookupValue}}',
        propertyName: '{{bundle.inputData.propertyName}}',
      },
      removeMissingValuesFrom: {},
    },
    inputFields: [
      {
        key: 'propertyName',
        label: 'Property name',
        type: 'string',
        helpText: 'the "thing" you are looking for e.g. \'population\'',
        required: false,
        list: false,
        altersDynamicFields: false,
      },
      {
        key: 'lookupValue',
        label: 'Lookup value',
        type: 'string',
        helpText: 'The value you are looking up e.g. Iceland',
        required: false,
        list: false,
        altersDynamicFields: false,
      },
    ],
  },
  key: 'lookup',
  noun: 'Lookup',
  display: {
    label: 'Lookup',
    description: '[This is a placeholder text]',
    hidden: false,
    important: true,
  },
};

test\searches\lookup.js

require('should');

const zapier = require('zapier-platform-core');

const App = require('../../index');
const appTester = zapier.createAppTester(App);

describe('Search - lookup', () => {
  zapier.tools.env.inject();

  it('should get an array', async () => {
    const bundle = {
      authData: {
        oauth_consumer_key: process.env.OAUTH_CONSUMER_KEY,
        oauth_consumer_secret: process.env.OAUTH_CONSUMER_SECRET,
        oauth_token: process.env.OAUTH_TOKEN,
        oauth_token_secret: process.env.OAUTH_TOKEN_SECRET,
        x_api_key: 'my-key-value-hard-coded'
      },

      inputData: {
        lookupValue: 'population',
        propertyName: 'Iceland'
      },
    };

    const results = await appTester(
      App.searches['lookup'].operation.perform,
      bundle
    );
    results.should.be.an.Array();
    results.length.should.be.aboveOrEqual(1);
    results[0].should.have.property('id');
  });
});

@sturlath I've fixed the bug in the linked PR. It won't be released for a bit yet, so you've got a couple of options if you want to use it right away:

  • edit the changed file in your local install to add the fix from the linked PR (just a pair of quotes). My copy of that file locally is at /Users/<username>/.nvm/versions/node/v10.13.0/lib/node_modules/zapier-platform-cli/src/utils/convert.js
  • clone this repo and run the CLI manually (something like <CLONE_LOCATION>/packages/cli/src/bin/run convert ...)

​Let me know if you've got any other questions!