Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-22279

Undefined array key "template_groups"

XMLWordPrintable

    • Icon: Problem report Problem report
    • Resolution: Won't fix
    • Icon: Trivial Trivial
    • None
    • 6.2.6
    • API (A)

      Steps to reproduce:

      I have the following simple template which I'm trying to compare/import with python-api library:

      zabbix_export:
        date: '2023-01-31T00:00:00Z'
        template_groups:
        - name: Templates
          uuid: 7df96b18c230490a9a0a9e2307226338
        templates:
        - groups:
          - name: Templates
          items:
          - key: agent.hostname
            name: bbb
            trends: '0'
            uuid: 450de98bddb848a7b9af63f7d4d59e72
            value_type: CHAR
          name: aaa
          template: aaa
          uuid: c7c00f6f1e334e77acb369b2f7120fe8
        version: '6.2'
      

      However I'm getting the error 'Undefined array key "template_groups"' in php/nginx logs

      Result:

      2023/01/30 11:43:47 [error] 775#775: *844993 FastCGI sent in stderr: "PHP message: PHP Warning:  Undefined array key "template_groups" in /usr/share/zabbix/include/classes/import/CConfigurationImportcompare.php on line 241PHP message: PHP Fatal error:  
      Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, null given in /usr/share/zabbix/include/classes/import/CConfigurationImportcompare.php:296
      
      Stack trace:
      
      #0 /usr/share/zabbix/include/classes/import/CConfigurationImportcompare.php(134): CConfigurationImportcompare->applyOptions()
      
      #1 /usr/share/zabbix/include/classes/import/CConfigurationImportcompare.php(84): CConfigurationImportcompare->compareByStructure()
      
      #2 /usr/share/zabbix/include/classes/api/services/CConfiguration.php(385): CConfigurationImportcompare->importcompare()
      
      #3 /usr/share/zabbix/include/classes/api/clients/CLocalApiClient.php(121): CConfiguration->importcompare()
      
      #4 /usr/share/zabbix/include/classes/core/CJsonRpc.php(75): CLocalApiClient->callMethod()
      
      #5 /usr/share/zabbix/api_jsonrpc.php(63): CJsonRpc->execute()
      
      #6 {main}
      
        thrown in /usr/share/zabbix/include/classes/import/CConfigurationImportcompare.php on line 296" while reading response header from upstream, client: 10.12.5.107, server: monitoring.acc.tag-aws.avira.net, request: "POST /api_jsonrpc.php HTTP/1.1", upst
      ream: "fastcgi://unix:/var/run/php/zabbix.sock:"
      

      Debug from zabbix-api:

      20: Set logging level to 5
      01/30/2023 12:43:46 PM 20: Set logging level to 5
      20: url: http://monitoring.example.com/api_jsonrpc.php
      01/30/2023 12:43:46 PM 20: url: http://monitoring.example.com/api_jsonrpc.php
      10: Trying to login with 'user.name':'md5(**************)'
      01/30/2023 12:43:46 PM 10: Trying to login with 'user.name':'md5(**************)'
      10: json_obj: {'jsonrpc': '2.0', 'method': 'user.login', 'params': {'user': 'user.name', 'password': '********'}, 'id': 0}
      01/30/2023 12:43:46 PM 10: json_obj: {'jsonrpc': '2.0', 'method': 'user.login', 'params': {'user': 'user.name', 'password': '********'}, 'id': 0}
      20: Sending: {"jsonrpc": "2.0", "method": "user.login", "params": {"user": "user.name", "password": "********"}, "id": 0}
      01/30/2023 12:43:46 PM 20: Sending: {"jsonrpc": "2.0", "method": "user.login", "params": {"user": "user.name", "password": "********"}, "id": 0}
      10: Sending headers: {'Content-Type': 'application/json-rpc', 'User-Agent': 'python/zabbix_api'}
      01/30/2023 12:43:46 PM 10: Sending headers: {'Content-Type': 'application/json-rpc', 'User-Agent': 'python/zabbix_api'}
      20: Response Code: 200
      01/30/2023 12:43:47 PM 20: Response Code: 200
      10: Response Body: {'jsonrpc': '2.0', 'result': 'af3381b651c31f6e5073bdc05964113e', 'id': 0}
      01/30/2023 12:43:47 PM 10: Response Body: {'jsonrpc': '2.0', 'result': 'af3381b651c31f6e5073bdc05964113e', 'id': 0}
      20: Creating ZabbixAPISubClass
      01/30/2023 12:43:47 PM 20: Creating ZabbixAPISubClass
      Going to do_request for <function checkauth.<locals>.ret at 0x7fc570520430> with opts {'format': 'yaml', 'rules': {'valueMaps': {'createMissing': True, 'updateExisting': True}, 'hosts': {'createMissing': True, 'updateExisting': True}, 'items': {'createMissing': True, 'updateExisting': True, 'deleteMissing': True}}, 'source': "zabbix_export:\n  date: '2023-01-31T00:00:00Z'\n  template_groups:\n  - name: Templates\n    uuid: 7df96b18c230490a9a0a9e2307226338\n  templates:\n  - groups:\n    - name: Templates\n    items:\n    - key: agent.hostname\n      name: bbb\n      trends: '0'\n      uuid: 450de98bddb848a7b9af63f7d4d59e72\n      value_type: CHAR\n    name: aaa\n    template: aaa\n    uuid: c7c00f6f1e334e77acb369b2f7120fe8\n  version: '6.2'\n"}
      01/30/2023 12:43:47 PM Going to do_request for <function checkauth.<locals>.ret at 0x7fc570520430> with opts {'format': 'yaml', 'rules': {'valueMaps': {'createMissing': True, 'updateExisting': True}, 'hosts': {'createMissing': True, 'updateExisting': True}, 'items': {'createMissing': True, 'updateExisting': True, 'deleteMissing': True}}, 'source': "zabbix_export:\n  date: '2023-01-31T00:00:00Z'\n  template_groups:\n  - name: Templates\n    uuid: 7df96b18c230490a9a0a9e2307226338\n  templates:\n  - groups:\n    - name: Templates\n    items:\n    - key: agent.hostname\n      name: bbb\n      trends: '0'\n      uuid: 450de98bddb848a7b9af63f7d4d59e72\n      value_type: CHAR\n    name: aaa\n    template: aaa\n    uuid: c7c00f6f1e334e77acb369b2f7120fe8\n  version: '6.2'\n"}
      10: json_obj: {'jsonrpc': '2.0', 'method': 'configuration.importcompare', 'params': {'format': 'yaml', 'rules': {'valueMaps': {'createMissing': True, 'updateExisting': True}, 'hosts': {'createMissing': True, 'updateExisting': True}, 'items': {'createMissing': True, 'updateExisting': True, 'deleteMissing': True}}, 'source': "zabbix_export:\n  date: '2023-01-31T00:00:00Z'\n  template_groups:\n  - name: Templates\n    uuid: 7df96b18c230490a9a0a9e2307226338\n  templates:\n  - groups:\n    - name: Templates\n    items:\n    - key: agent.hostname\n      name: bbb\n      trends: '0'\n      uuid: 450de98bddb848a7b9af63f7d4d59e72\n      value_type: CHAR\n    name: aaa\n    template: aaa\n    uuid: c7c00f6f1e334e77acb369b2f7120fe8\n  version: '6.2'\n"}, 'auth': 'af3381b651c31f6e5073bdc05964113e', 'id': 1}
      01/30/2023 12:43:47 PM 10: json_obj: {'jsonrpc': '2.0', 'method': 'configuration.importcompare', 'params': {'format': 'yaml', 'rules': {'valueMaps': {'createMissing': True, 'updateExisting': True}, 'hosts': {'createMissing': True, 'updateExisting': True}, 'items': {'createMissing': True, 'updateExisting': True, 'deleteMissing': True}}, 'source': "zabbix_export:\n  date: '2023-01-31T00:00:00Z'\n  template_groups:\n  - name: Templates\n    uuid: 7df96b18c230490a9a0a9e2307226338\n  templates:\n  - groups:\n    - name: Templates\n    items:\n    - key: agent.hostname\n      name: bbb\n      trends: '0'\n      uuid: 450de98bddb848a7b9af63f7d4d59e72\n      value_type: CHAR\n    name: aaa\n    template: aaa\n    uuid: c7c00f6f1e334e77acb369b2f7120fe8\n  version: '6.2'\n"}, 'auth': 'af3381b651c31f6e5073bdc05964113e', 'id': 1}
      20: Sending: {"jsonrpc": "2.0", "method": "configuration.importcompare", "params": {"format": "yaml", "rules": {"valueMaps": {"createMissing": true, "updateExisting": true}, "hosts": {"createMissing": true, "updateExisting": true}, "items": {"createMissing": true, "updateExisting": true, "deleteMissing": true}}, "source": "zabbix_export:\n  date: '2023-01-31T00:00:00Z'\n  template_groups:\n  - name: Templates\n    uuid: 7df96b18c230490a9a0a9e2307226338\n  templates:\n  - groups:\n    - name: Templates\n    items:\n    - key: agent.hostname\n      name: bbb\n      trends: '0'\n      uuid: 450de98bddb848a7b9af63f7d4d59e72\n      value_type: CHAR\n    name: aaa\n    template: aaa\n    uuid: c7c00f6f1e334e77acb369b2f7120fe8\n  version: '6.2'\n"}, "auth": "af3381b651c31f6e5073bdc05964113e", "id": 1}
      01/30/2023 12:43:47 PM 20: Sending: {"jsonrpc": "2.0", "method": "configuration.importcompare", "params": {"format": "yaml", "rules": {"valueMaps": {"createMissing": true, "updateExisting": true}, "hosts": {"createMissing": true, "updateExisting": true}, "items": {"createMissing": true, "updateExisting": true, "deleteMissing": true}}, "source": "zabbix_export:\n  date: '2023-01-31T00:00:00Z'\n  template_groups:\n  - name: Templates\n    uuid: 7df96b18c230490a9a0a9e2307226338\n  templates:\n  - groups:\n    - name: Templates\n    items:\n    - key: agent.hostname\n      name: bbb\n      trends: '0'\n      uuid: 450de98bddb848a7b9af63f7d4d59e72\n      value_type: CHAR\n    name: aaa\n    template: aaa\n    uuid: c7c00f6f1e334e77acb369b2f7120fe8\n  version: '6.2'\n"}, "auth": "af3381b651c31f6e5073bdc05964113e", "id": 1}
      10: Sending headers: {'Content-Type': 'application/json-rpc', 'User-Agent': 'python/zabbix_api'}
      01/30/2023 12:43:47 PM 10: Sending headers: {'Content-Type': 'application/json-rpc', 'User-Agent': 'python/zabbix_api'}
      Traceback (most recent call last):
        File "/home/denis/.local/lib/python3.10/site-packages/zabbix_api.py", line 279, in do_request
          response = opener.open(request, timeout=self.timeout)
        File "/usr/lib/python3.10/urllib/request.py", line 525, in open
          response = meth(req, response)
        File "/usr/lib/python3.10/urllib/request.py", line 634, in http_response
          response = self.parent.error(
        File "/usr/lib/python3.10/urllib/request.py", line 563, in error
          return self._call_chain(*args)
        File "/usr/lib/python3.10/urllib/request.py", line 496, in _call_chain
          result = func(*args)
        File "/usr/lib/python3.10/urllib/request.py", line 643, in http_error_default
          raise HTTPError(req.full_url, code, msg, hdrs, fp)
      urllib.error.HTTPError: HTTP Error 500: Internal Server Error 

      Expected:

      Template is compared/imported

            elina.kuzyutkina Elina Kuzyutkina (Inactive)
            denisby Denis Kot
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: