Remember, the openAB JSONPATH transformation service is not exactly JSONPATH. For example, it will never return an array.
I think the transform for an invalid path will throw a behind the scenes exception, as well as returning the input string. Do you see a WARN in your openhab.log?
I think you can detect that in a rule with try-catch
EDIT - I had a play but cannot get try-catch to give any help here. You’re left with checking results == source to detect the problem.
I think the OP set up a deliberate “missing field error” to show how the results are not what you might expect.
JSON sources may have fields that are present only sometimes.
How to deal with that in rules is not obvious.
Yes, it returns the original string when it doesn’t find a match. I hate that, BTW. Personally, I wish it would return null. Even an empty string would be better than the returning original string.
There may already be an issue. I’m not sure. The challenge will be that changing what’s returned will break rules for everyone who does the string equals comparison to determine if there was no match.
Good luck with that. It’s about the “rules of OH transformation”, not JSONPATH in particular.
It may be something that could reconsidered for OH3, but you will not get it for OH2 because it would be a needless breaking change.
More than that, development of openHAB core has moved on to OH 3.0, so there will not be any more updates to OHC in 2.5.x releases. You’ll need to be at least a Contributor of the openHAB Github organization to see this, but there are more details here…