[ZBX-22130] JSON null is converted to "null" Created: 2022 Dec 22  Updated: 2024 Apr 10  Resolved: 2024 Feb 05

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Proxy (P)
Affects Version/s: 6.0.12
Fix Version/s: 6.0.27rc1, 6.4.12rc1, 7.0.0beta2, 7.0 (plan)

Type: Problem report Priority: Trivial
Reporter: FP Assignee: Andris Zeila
Resolution: Fixed Votes: 5
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File Input data.png     PNG File Item Prototype.png     PNG File Latest values.png     PNG File Trigger Prototype.png    
Team: Team A
Sprint: S2401-2
Story Points: 0.25

 Description   

Steps to reproduce:

  1. Create an item prototype that uses JSON path preprocessing to extract a field. This field can either be a JSON string or JSON null.
  2. Add a trigger prototype with the following expression: 
    length(last(/BackupPC/backuppc.host[{#HOST},error]))>0 
  1. Monitor the template via a Zabbix Proxy
  2. Since Zabbix Proxy 6.0.12 a JSON null is converted to the JSON string "null" causing the trigger to fire.

Expected:

  • JSON null should not be converted to the string "null"


 Comments   
Comment by Yurii Polenok [ 2023 Feb 15 ]

Upgraded from 6.2.4 to 6.2.7.
Result of db.odbc.get from oracle db:

[{
"MONITORNAME": "Create_Autodiscover",
"CRITICAL": null
}, {
"MONITORNAME": "Extract_generic_data_w33",
"CRITICAL": null
}]

jsonpath:

$[?(@.MONITORNAME=="Create_Autodiscover")].CRITICAL

Return:

[null]

But it should be just an empty array:

[]

Not sure, but it seems changed after ZBXNEXT-8040 or ZBXNEXT-8009

Comment by Yurii Polenok [ 2023 Feb 15 ]

Also similar problem.
Data from odbc:

[{
"NAME": "versus",
"REPORT_NAME": null,
"SEVERITY": "major",
"NOT_GENERATED": "0",
"CONTENT_SEND_ERROR": "0",
"INFRA_SEND_ERROR": null,
"SENDING_HALTED": "0",
"NGC_JOB_HALTED": "0"
}, {
"NAME": "mansion",
"REPORT_NAME": null,
"SEVERITY": "critical",
"NOT_GENERATED": "0",
"CONTENT_SEND_ERROR": "0",
"INFRA_SEND_ERROR": "0",
"SENDING_HALTED": "0",
"NGC_JOB_HALTED": "0"
}]

jsonpath:

$[?(@.NAME=="versus" && @.SEVERITY=="major" && (@.NOT_GENERATED>0 || @.CONTENT_SEND_ERROR>0 || @.INFRA_SEND_ERROR>0 || @.SENDING_HALTED>0 || @.NGC_JOB_HALTED>0))]

Result:

[{
"CONTENT_SEND_ERROR": "0",
"CASINO_NAME": "versus",
"INFRA_SEND_ERROR": null,
"NGC_JOB_HALTED": "0",
"SENDING_HALTED": "0",
"REPORT_NAME": null,
"NOT_GENERATED": "0",
"SEVERITY": "major"
}]

Why "INFRA_SEND_ERROR": null more then 0?
Null not integer.

Comment by Sandro Bordacchini [ 2023 Mar 07 ]

I have the same exact problem with a backuppc monitored host and upgraded zabbix from version 1:6.0.5-1+debian11 up to version 1:6.0.13-1+debian11.
My scenario does not include a zabbix proxy, i am directly using an agent2

Comment by Przemyslaw Jagielski [ 2023 Apr 17 ]

On version's from 6.2 branch, i've the same error. 

Comment by Sandro Bordacchini [ 2023 Apr 28 ]

For more info on my issue please check out this issue I opened on a zabbix template github.

https://github.com/yurtesen/zabbix_backuppc/issues/8

Comment by Simon D. [ 2023 Jun 01 ]

Same problem here.

I've tried to add a preprocessing step (on first place) who replace null with 0

But value is not changed. Perhaps I've made a mistake

Comment by Daniel B [ 2023 Sep 14 ]

Same Problem here, updating from 6.0.6 to anything newer breaks some custom templates. The triggers are firing, because the JSONPath return "null", not nothing.

Comment by Sandro Bordacchini [ 2023 Dec 19 ]

No ETA for this issue? Thanks...

Comment by Andris Zeila [ 2024 Jan 18 ]

The null value comparison in jsonpath expression is going to be fixed here. null value is less than all other value types.

The null value returned as 'null' rather than empty string '' seems to be universal approach going by multiple online jsonpath testers I checked. Either way it's ambiguous result - after returning as string there is no way to tell if the original value was null or 'null' or '' whatever approach is chosen.

Possible workarounds for the original issue:

  • Change trigger to check for null string - last(/BackupPC/backuppc.host[ {#HOST}

    ,error])<>"null"

  • Add 'matches regular expression' preprocessing step to check for null with 'on fail' set to ''.

Of course with this real errors containing string 'null' would be ignored, but is is likely to have such error? That depends on the application.

Comment by Andris Zeila [ 2024 Feb 02 ]

Released ZBX-22130 in:

  • pre-6.0.27rc1 91bfae6d21b
  • pre-6.4.12rc1 9424b9788cc
  • pre-7.0.0beta2 ff9594ab0c6
Generated at Wed May 14 08:07:21 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.