Why am I Getting a "Cannot read properties of undefined" Error When Integrating Pipedream SDK in My Node.js Application?

This topic was automatically generated from Slack. You can find the original thread here.

Hello everyone :wave:
I am integrating @pipedream/sdk in my Node.js application.
I am using this function to deploy a trigger:

 const { data: deployedTrigger } = await pd.deployTrigger({
    externalUserId: "testing-pookiy",
    triggerId: {
      key: "github-new-or-updated-pull-request"
    },
    configuredProps: {
      github: {
        authProvisionId: "apn_yghMzMj",
      },
      repoFullname: 'HamzaPooki/Testing_repo'
    },
    webhookUrl: "https://2e41-182-183-42-220.ngrok-free.app/api/composio/pipedream-webhook"
  });

But I am getting this error:

Error: HTTP error! status: 422, body: {"error":"observation error","err":null,"observations":[{"k":"hook","ts":1744626456352,"h":"activate"},{"k":"db.get","ts":1744626456551,"pn":"db","key":"webhookId"},{"k":"error","ts":1744626456553,"err":{"name":"TypeError","message":"Cannot read properties of undefined (reading 'endpoint')","stack":"TypeError: Cannot read properties of undefined (reading 'endpoint')\n    at Object.createWebhook (file:///tmp/__pdg__/dist/code/c3b2d0e5edbefa064cd8e67b81ff4612a6e85259e403c1219943477e7eb69e82/code/sources/common/common-flex.mjs:109:28)\n    at Object.checkWebhookCreation (file:///tmp/__pdg__/dist/code/c3b2d0e5edbefa064cd8e67b81ff4612a6e85259e403c1219943477e7eb69e82/code/sources/common/common-flex.mjs:85:20)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async Object.activate (file:///tmp/__pdg__/dist/code/c3b2d0e5edbefa064cd8e67b81ff4612a6e85259e403c1219943477e7eb69e82/code/sources/common/common-flex.mjs:214:7)\n    at async /var/task/node_modules/@lambda-v2/component-runtime/src/deployedComponentMain.js:78:13\n    at async captureObservations (/var/task/node_modules/@lambda-v2/component-runtime/src/captureObservations.js:28:5)\n    at async deployedComponentMain (/var/task/node_modules/@lambda-v2/component-runtime/src/deployedComponentMain.js:44:20)\n    at async MessagePort.\u003canonymous\u003e (file:///var/task/component_maker.mjs:181:9)"}}]}
    at x.makeRequest (file:///Users/hamzapy/Documents/PookiDevs/Projects/Pooki-MCP-Servers/node_modules/@pipedream/sdk/dist/chunk-G7ULQDUE.js:1:1744)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async test (file:///Users/hamzapy/Documents/PookiDevs/Projects/Pooki-MCP-Servers/routes/composio.js:267:37)

I am getting this same error for triggerId: ‘gmail-new-email-received’ too.

Hey , it looks like your configuredProps is missing some configurations

Use our demo app to see what are the values for configuredProps that you need! Go through the form and configure everything you need there and after clicking on submit, you’ll see configured_props in the payload where you can copy and paste to your app

I have updated my configured props same as the above demo app:

{
    "external_user_id":"testing-pookiy",
    "id":"github-new-or-updated-pull-request",
    "configured_props":{
        "github": {
            "authProvisionId":"apn_EOhzb03"
        },
        "repoFullname": {
            "__lv": {
                "label": "HamzaPooki/Testing_repo",
                "value": "HamzaPooki/Testing_repo"
            }
        }
    },
    "webhook_url":"https://0acf-182-183-42-220.ngrok-free.app/api/composio/test-webhook"
}

Using this API: https://api.pipedream.com/v1/connect/proj_RMsr6mB/triggers/deploy

Still it is not working - I am getting same error “Cannot read properties of undefined (reading ‘endpoint’)”

you also have to add the service db and http url:

    "configured_props": {
      "github": {
        "authProvisionId": "apn_EOhzb03"
      },
      "repoFullname": {
        "__lv": {
          "label": "HamzaPooki/Testing_repo",
          "value": "HamzaPooki/Testing_repo"
        }
      },
      "db": {
        "type": "$.service.db"
      },
      "http": {
        "endpoint_url": "https://0acf-182-183-42-220.ngrok-free.app/api/composio/test-webhook"
      }
    },

btw i advise you to recreate your webhook url since now it’s public

Sure - its a temporary webhook url.
Let me try it with the above props.

Attached is the screenshot with the payload including the above props.
Still the same error.
I think the error is in the specific file for Github triggers?

hmm can you try adding this duplicate endpoint? yeah maybe it’s a bug in this trigger

      "http": {
        "endpoint": "https://0acf-182-183-42-220.ngrok-free.app/api/composio/test-webhook",
        "endpoint_url": "https://0acf-182-183-42-220.ngrok-free.app/api/composio/test-webhook"
      }

Still not working.

do you have any insights here?

Mohammad, are you an admin on that repo?

Yes.

Did you call reloadProps after configuring the repo? That should return the new set of configurable props that you need to define (it’s actually not $.service.db and $.interface.http), but it should also return eventTypes, which is expecting an array of event types that you want to subscribe to

So I believe that’s what’s missing from your payload on deployTrigger

Yes got it.
Finally I was able to create a trigger.
First I called this API (https://api.pipedream.com/v1/connect/${project_id}/components/props)
with github trigger payload and got the dynamicProps id.

I added this dynamicProps id in payload for this API (https://api.pipedream.com/v1/connect/${project_id}/components/props) and successfully created the trigger. :tada:

Thanks for the help.

One question - For every trigger like for Gmail, Slack or some other app - Do I have to add dynamicPropId for each one?

Thank you !

If there are dynamic props that are returned, then yes you’ll need to keep that dynamicPropsId in state and include it in the payload (but not all triggers / actions require it)

Okay sure. Thanks! :100: