Skip to content

Bug: Accessing undefined property with a function results in an error #584

@RafalWilinski

Description

@RafalWilinski

Consider the following JSONata expression:

(
  $foo := {};
  $foo.bar[$contains("123", $lowercase())]
)

Result: undefined is not an object (evaluating 'e.apply')

Note that if I replace $contains("123", $lowercase()) with an actual result of this call (either true or false) it works properly and returns undefined.

Link to JSONata Exerciser: https://try.jsonata.org/gnq5qjXA_


Edit:

Digging into this a bit more, we discovered that when the second arg of $contains resolves to undefined - it crashes: https://try.jsonata.org/2cN8l5GkQ

Edit 2:

Looks like, if the second arg is not a string - then JSONata thinks it’s a matcher function: https://github.com/jsonata-js/jsonata/blob/master/src/functions.js#L349-L354

Fix: Stedi#18

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions