katt icon indicating copy to clipboard operation
katt copied to clipboard

Storing key value will always succeed even if key does not exists.

Open mekanixdk opened this issue 6 years ago • 2 comments

GET http://httpbin.org/cache
> User-Agent: KATT
< 200
< Content-Type: application/json
{
    "foo": "{{>bar}}"
}

The key foo does not exist so I would have assumed this would fail. It does not and bar will get the value undefined

So is this an expected behaviour or a bug?

mekanixdk avatar Jul 03 '18 08:07 mekanixdk

I would say it's expected. But i can also see how you may want to check for existence AND store value.

The primary reason why i say it's expected is the "AND" above i.e. KATT does one thing today, store the value, not two things.

andreineculau avatar Jul 03 '18 18:07 andreineculau

If it is expected then it would be hard to change as it would break existing tests :-)

It is relative easy to work around: repeat the test - first run check the existence of the value and next time around store it.

Maybe a heads up in the documentation could be helpful? And a new feature {{>>bar}} that will do both? :-)

mekanixdk avatar Jul 11 '18 12:07 mekanixdk