[ZBX-10413] importing template gives error about item description Created: 2016 Feb 19  Updated: 2017 May 30  Resolved: 2016 Mar 23

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: API (A)
Affects Version/s: 3.0.0
Fix Version/s: 3.0.2rc1, 3.2.0alpha1

Type: Incident report Priority: Minor
Reporter: lamba Assignee: Unassigned
Resolution: Fixed Votes: 1
Labels: import, xml
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Note that this template can be imported into 2.4.6 successfully.

With a template from the zabbix wiki for cisco devices:

https://www.zabbix.org/wiki/File:Template_Cisco_Catalyst_Switches-20141206.xml

The error message is:

Illegal string offset 'params' [conf.import.php:173 ? CFrontendApiWrapper->import() ? CApiWrapper->__call() ? CFrontendApiWrapper->callMethod() ? CApiWrapper->callMethod() ? CFrontendApiWrapper->callClientMethod() ? CLocalApiClient->callMethod() ? call_user_func_array() ? CConfiguration->import() ? CXmlImportReader->read() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() in include/classes/import/readers/CXmlImportReader.php:102]
Illegal string offset 'trapper_hosts' [conf.import.php:173 ? CFrontendApiWrapper->import() ? CApiWrapper->__call() ? CFrontendApiWrapper->callMethod() ? CApiWrapper->callMethod() ? CFrontendApiWrapper->callClientMethod() ? CLocalApiClient->callMethod() ? call_user_func_array() ? CConfiguration->import() ? CXmlImportReader->read() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() in include/classes/import/readers/CXmlImportReader.php:102]
Illegal string offset 'snmp_community' [conf.import.php:173 ? CFrontendApiWrapper->import() ? CApiWrapper->__call() ? CFrontendApiWrapper->callMethod() ? CApiWrapper->callMethod() ? CFrontendApiWrapper->callClientMethod() ? CLocalApiClient->callMethod() ? call_user_func_array() ? CConfiguration->import() ? CXmlImportReader->read() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() in include/classes/import/readers/CXmlImportReader.php:102]
Illegal string offset 'snmp_oid' [conf.import.php:173 ? CFrontendApiWrapper->import() ? CApiWrapper->__call() ? CFrontendApiWrapper->callMethod() ? CApiWrapper->callMethod() ? CFrontendApiWrapper->callClientMethod() ? CLocalApiClient->callMethod() ? call_user_func_array() ? CConfiguration->import() ? CXmlImportReader->read() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() in include/classes/import/readers/CXmlImportReader.php:102]
Illegal string offset 'snmp_port' [conf.import.php:173 ? CFrontendApiWrapper->import() ? CApiWrapper->__call() ? CFrontendApiWrapper->callMethod() ? CApiWrapper->callMethod() ? CFrontendApiWrapper->callClientMethod() ? CLocalApiClient->callMethod() ? call_user_func_array() ? CConfiguration->import() ? CXmlImportReader->read() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() in include/classes/import/readers/CXmlImportReader.php:102]
Illegal string offset 'snmpv3_securityname' [conf.import.php:173 ? CFrontendApiWrapper->import() ? CApiWrapper->__call() ? CFrontendApiWrapper->callMethod() ? CApiWrapper->callMethod() ? CFrontendApiWrapper->callClientMethod() ? CLocalApiClient->callMethod() ? call_user_func_array() ? CConfiguration->import() ? CXmlImportReader->read() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() in include/classes/import/readers/CXmlImportReader.php:102]
Illegal string offset 'snmpv3_securitylevel' [conf.import.php:173 ? CFrontendApiWrapper->import() ? CApiWrapper->__call() ? CFrontendApiWrapper->callMethod() ? CApiWrapper->callMethod() ? CFrontendApiWrapper->callClientMethod() ? CLocalApiClient->callMethod() ? call_user_func_array() ? CConfiguration->import() ? CXmlImportReader->read() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() in include/classes/import/readers/CXmlImportReader.php:102]
Illegal string offset 'snmpv3_authpassphrase' [conf.import.php:173 ? CFrontendApiWrapper->import() ? CApiWrapper->__call() ? CFrontendApiWrapper->callMethod() ? CApiWrapper->callMethod() ? CFrontendApiWrapper->callClientMethod() ? CLocalApiClient->callMethod() ? call_user_func_array() ? CConfiguration->import() ? CXmlImportReader->read() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() in include/classes/import/readers/CXmlImportReader.php:102]
Illegal string offset 'snmpv3_privpassphrase' [conf.import.php:173 ? CFrontendApiWrapper->import() ? CApiWrapper->__call() ? CFrontendApiWrapper->callMethod() ? CApiWrapper->callMethod() ? CFrontendApiWrapper->callClientMethod() ? CLocalApiClient->callMethod() ? call_user_func_array() ? CConfiguration->import() ? CXmlImportReader->read() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() ? CXmlImportReader->xmlToArray() in include/classes/import/readers/CXmlImportReader.php:102]
Invalid XML tag "/zabbix_export/hosts/host(1)/items/item(1)": the tag "description" is missing.


 Comments   
Comment by Alexander Vladishev [ 2016 Feb 23 ]

Thank you for a report.

This XML file is incorrect and cannot be imported into 3.0.x. Under ZBX-7654 we introduced strict validation of XML files.

In any case errors like 'Illegal string offset' must be fixed.

Comment by Oleg Egorov (Inactive) [ 2016 Mar 18 ]

RESOLVED IN svn://svn.zabbix.com/branches/dev/ZBX-10413 r59068

Comment by Oleg Egorov (Inactive) [ 2016 Mar 18 ]

(1) [F] Translation strings

Added translation strings:

  • unexpected text "%1$s"
  • Cannot read XML: %1$s.
  • XML is empty
  • %1$s [Line: %2$s | Column: %3$s]

Removed translation strings:

  • XML file contains warning %1$s:
  • XML file contains error %1$s:
  • XML file contains fatal error %1$s:

sasha Updated list of the strings. Please check.

RESOLVED

oleg.egorov Updated list for (4). RESOLVED.

sasha CLOSED

Comment by Alexander Vladishev [ 2016 Mar 21 ]

(2) Handling of tags with same name as attribute is not resolved.

sasha RESOLVED in r59074

oleg.egorov CLOSED

Comment by Alexander Vladishev [ 2016 Mar 21 ]

(3) Fatal PHP error while reading this XML:

<?xml version="1.0"?>
<zabbix_export version="1.0" date="09.01.10" time="14.23">
    <host name="aaa">
        <name>Zabbix</name>p
        <item type="3" key="icmpping" value_type="3">
        </item>
    </host>
</zabbix_export>

Error message:

Cannot use string offset as an array in include/classes/import/readers/CXmlImportReader.php on line 109, referer: conf.import.php?rules_preset=template&sid=...

sasha RESOLVED in r59074

oleg.egorov CLOSED

Comment by Oleg Egorov (Inactive) [ 2016 Mar 22 ]

(4) Missed check for empty XML

XMLReader::XML(): Empty string supplied as input [conf.import.php:173 → CFrontendApiWrapper->import() → CApiWrapper->__call() → CFrontendApiWrapper->callMethod() → CApiWrapper->callMethod() → CFrontendApiWrapper->callClientMethod() → CLocalApiClient->callMethod() → call_user_func_array() → CConfiguration->import() → CXmlImportReader->read() → XMLReader->XML() in include\classes\import\readers\CXmlImportReader.php:53]
XMLReader::read(): Load Data before trying to read [conf.import.php:173 → CFrontendApiWrapper->import() → CApiWrapper->__call() → CFrontendApiWrapper->callMethod() → CApiWrapper->callMethod() → CFrontendApiWrapper->callClientMethod() → CLocalApiClient->callMethod() → call_user_func_array() → CConfiguration->import() → CXmlImportReader->read() → CXmlImportReader->xml_to_array() → XMLReader->read() in include\classes\import\readers\CXmlImportReader.php:70]
Argument 1 passed to CXmlValidator::validate() must be of the type array, null given, called in C:\xampp\htdocs\ZBX-10413\frontends\php\include\classes\api\services\CConfiguration.php on line 79 and defined [conf.import.php:173 → CFrontendApiWrapper->import() → CApiWrapper->__call() → CFrontendApiWrapper->callMethod() → CApiWrapper->callMethod() → CFrontendApiWrapper->callClientMethod() → CLocalApiClient->callMethod() → call_user_func_array() → CConfiguration->import() → CXmlValidator->validate() in include\classes\import\validators\CXmlValidator.php:50]
Invalid XML tag "/": an array is expected. [conf.import.php:173 → CFrontendApiWrapper->import() → CApiWrapper->__call() → CFrontendApiWrapper->callMethod() → CApiWrapper->callMethod() → CFrontendApiWrapper->callClientMethod() → CLocalApiClient->callMethod() → call_user_func_array() → CConfiguration->import() → CXmlValidator->validate() → CXmlValidatorGeneral->validate() → CXmlValidatorGeneral->validateData() → CXmlValidatorGeneral->validateArray() in include\classes\import\validators\CXmlValidatorGeneral.php:74]

RESOLVED in r59089, please review

sasha CLOSED

Comment by Oleg Egorov (Inactive) [ 2016 Mar 22 ]

Fixed in pre-3.0.2rc1 r59100 and pre-3.1.0 (trunk) r59099.

Comment by Paul afk [ 2017 May 19 ]

Hello,

Iv you want to migrate from Zabbix 3.4 to Zabbix 3.2 here is a small script

echo "#!/bin/bash
replace "<version>3.4</version>" "<version>3.2</version>" – $1
replace "<snmp_community/>" "<snmp_community/><multiplier>0</multiplier>" – $1
replace "<snmpv3_contextname/>" "<snmpv3_contextname/><delta>0</delta>" – $1
replace "<snmpv3_privpassphrase/>" "<snmpv3_privpassphrase/><formula>1</formula>" – $1
replace "<ipmi_sensor/>" "<ipmi_sensor/><data_type>0</data_type>" – $1
grep preprocessing $1 " > a

./a template.xml

if <preprocessing> or <preprocessing/> tags appear, please remove them (also remove content inside these tags) from the .xml you want to import in Zabbix 3.2 webinterface
Be aware to manually add on *Use custom multiplier* and *Store as* values from these tags

Generated at Fri Apr 19 09:19:24 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.