This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.

⚠️ We've moved!

Hi there!

To reduce project dependency on 3rd party paid services the StackStorm TSC has decided to move the Q/A from this forum to Github Discussions. This will make user experience better integrated with the native Github flow, as well as the questions closer to the community where they can provide answers.

Use 🔗 Github Discussions to ask your questions.

Jinja possibility to ignore undefined error or respond with None or similar

Hi,

I have several workflows using jinja expressions looping through objects or just get a single value. These objects do not always look the same and sometimes part of these objects are not available at all. In this case the workflow fails as it can not catch a specific value. I can fix it by using several if statements to check if something is available but it is really annoying if we talk about nested dicts.

e.g.

{{ ctx().search_result.alert_type_details.detail.srcipv4 }}

Sometimes there is no section “detail”. Then I get the error:

UndefinedError: 'dict object' has no attribute 'detail'"

even

{{ ctx().search_result.alert_type_details.detail.srcipv4 | default('None ') }}

is not working as this would only work if srcipv4 is missing.

In another case maybe the whole “alert_type_details” section is not there, therefore it is really annoying to catch this errors using if statements or multiple default tests.

Is there a handy possibility to ignore these Undifined errors and instead respond with None, an empty string, dict, … whatever?

Thanks.

Nikolas