Breaking Change: kv() Throws an Error When a Key Is Missing

KV function errors on missing key

New default behavior of the KV function

Before Kestra 0.22, the kv() function had the property errorOnMissing set to false by default. It was changed to true to align with the rest of the system — for example, the secret() function throws an error when the secret is missing.

If you want to keep the previous behavior of returning null without an error when attempting to fetch non-existing KV-pairs, use the syntax "{{kv('NON_EXISTING_KV_PAIR', errorOnMissing=false)}}".

Before Kestra 0.22

id: myflow
namespace: company.team
tasks:
- id: this_will_return_null
type: io.kestra.plugin.core.log.Log
message: Hello {{kv('NON_EXISTING_KV_PAIR')}} # Hello

After Kestra 0.22

This flow will fail because the kv() function will throw an error when the key is missing:

id: myflow
namespace: company.team
tasks:
- id: this_will_fail
type: io.kestra.plugin.core.log.Log
message: Hello {{kv('NON_EXISTING_KV_PAIR')}} # Error

To keep the previous behavior, use the errorOnMissing=false syntax:

id: myflow
namespace: company.team
tasks:
- id: this_will_fail
type: io.kestra.plugin.core.log.Log
message: Hello {{kv('NON_EXISTING_KV_PAIR', errorOnMissing=false)}} # Hello

Was this page helpful?