How to Trigger and Debug the `deploy` Function after Deploying a Broken Source Code using the CLI?

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

If I’ve got code I want to test in a source’s deploy function, how can I trigger it again after deploying it with the cli? I basically just want to debug that function since it seems like the Discourse new-posts-added source is broken. Using it in a workflow as a trigger shows no events when testing nor does it load the initial events pulled by the call to the Discord REST API. But when using the CLI to deploy it works fine.

No matter what there’s a bug in categories configuration. It says to “leave blank to watch all categories” but the drop down forces you to choose at least one.

The deploy function runs once once, and doesn’t run anytime again in a source’s lifecycle. That’s different from the activate and deactivate functions

Do you see anything in the source’s logs?

Yeah, I was hoping there was a better way to test code in deploy than to have to redeploy every time.

I’m adding debug statements.

There’s an error trying to delete the webhook on Discourse

but that doesn’t seem to affect the deploy issue

No matter what there’s a bug in categories configuration. It says to “leave blank to watch all categories” but the drop down forces you to choose at least one.
Yeah that’s strange, the prop should be optional

I get the latest posts as events on deploy… but it’s using the REST API to do that… I think the webhooks aren’t being generated properly.

Hmm got it

The deploy function will usually use the API to fetch historical events

the webhook calls are reverse engineered so there’s probably an issue there… or with permissions in discord

And then after it’s deployed, it should create a webhook in Discourse and start receiving new events through taht

Yeah, that deploy pull works fine when run with pd dev

but used as a trigger it does nothing.

Have you double checked the permissions for your API Key?

Yeah, but I’ll do it again just in case lol

We use that trigger internally and for some automations

it’s all users and global scope