[ZBX-13556] Not possible to use '-' character in jsonpath expression Created: 2018 Feb 28  Updated: 2024 Apr 10  Resolved: 2018 Apr 06

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Documentation (D)
Affects Version/s: 3.4.7, 4.0.0alpha4
Fix Version/s: 4.0 (plan)

Type: Incident report Priority: Trivial
Reporter: Vladislavs Sokurenko Assignee: Martins Valkovskis
Resolution: Fixed Votes: 0
Labels: dependentitems, jsonpath, preprocessing
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File patch.diff    
Issue Links:
Causes
caused by ZBXNEXT-3863 Extend item preprocessing with jsonpa... Closed
Team: Team A
Sprint: Sprint 30, Sprint 31
Story Points: 0

 Description   

Create dependent item with following jsonpath expression

$.header.Content-Type

And receive such json through Zabbix Trapper

{"header": {"Content-Type": "text/html; charset=UTF-8"}}

Actual:

item "Zabbix server:Set-Cookie" became not supported: Item preprocessing step #1 failed: cannot extract value from json by path "$.header.Content-Type": object not found starting with json path: "Content-Type"

Expected:
text/html; charset=UTF-8 is successfully extracted

Patch attached, though should consider allowing even more symbols.



 Comments   
Comment by Glebs Ivanovskis (Inactive) [ 2018 Mar 01 ]

Patch is not attached.

Comment by Vladislavs Sokurenko [ 2018 Mar 01 ]

Thanks !

Comment by Viktors Tjarve [ 2018 Mar 26 ]

Fixed in development branches:
svn://svn.zabbix.com/branches/dev/ZBX-13556
and
svn://svn.zabbix.com/branches/dev/ZBX-13556-40 (added test ceases)

Comment by Andris Zeila [ 2018 Mar 28 ]

After the changes json patch components can contain any characters except $@.[],:?(). This means that the following paths would be valid:

  • $.a b.c
  • $.a#b.c
  • $.a*b.c (actually * is used in jsonpath as wildcard and should be reserved too)

They do look strange. Plus control characters would be accepted too. I think they original patch plus check for unicode characters would be better.

wiper Actually accepting any unicode character would lead us to unknown territory as well. I looked into some jsonpath online parsers - the accepted symbols depends on implementation (which is not surprising as there is not strict jsonpath specification).

Comment by Andris Zeila [ 2018 Apr 03 ]

(1) [D] Document that only alphanumeric + underscore characters can be used in jsonpath dot notation ($.a.b.c). If the json object name contains other characters then bracket notation ($['a']['b']['c']) must be used. Both notations can be mixed ($.a['b'].c).

martins-v Added to:

Please review.

wiper Looks good.
CLOSED

Generated at Thu Apr 25 18:38:16 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.