Filter / exists condition yields JSON parsing error

Hello!

I’m using the Twitter integration, and I’m querying for some particular tweets.
I then apply a Filter to the tweets returned, to check only tweets that contain an image.
I use an Exists condition to only continue the workflow if that condition is met.
In the case of my image, I check that the following key exists:

{{steps.trigger.event.entities.media[0].media_url_https}}`

But I’m getting the following error:

SyntaxError
Unexpected token h in JSON at position 0

The value in that key is just a string.
And since it’s a link to an image stored on Twitter, it’s a string containing a URL, which of course starts with an h.
For example, a value in that field is: https://pbs.twimg.com/media/FRCIzy0WQAEC668.jpg

Does the filter assume that the key’s value needs to be some JSON object or array? So it’s not possible to check for the existence of a value?

I haven’t been able to find the documentation on Filter to better understand how to create my exist condition. If you can point me at the right direction, I’d be grateful.
Thanks in advance for your help.

Hi @glaforge ,

First off, welcome to the Pipedream community. Happy to have you!

You’re understanding the Filter action correctly, but just one tidbit that might solve the issue for you.

The steps.trigger.event.entities.media path won’t always exist, because not all tweets have images.

Before the data is passed into the Filter, make sure you’re safely accessing that data:

`{{steps.trigger.event.entities?.media[0]?.media_url_https}}

Now, if the steps.trigger.event.entities.media array doesn’t exist at all, instead of throwing an exception, the result will return undefined which the Filter should be able to handle.

Hope this helps!