[ZBX-25421] Unexpected parameter "automatic" when adding host tags via API Created: 2024 Oct 21  Updated: 2025 Mar 03  Resolved: 2025 Mar 03

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: API (A)
Affects Version/s: 7.0.4
Fix Version/s: None

Type: Problem report Priority: Trivial
Reporter: Markku Leiniö Assignee: Marianna Zvaigzne
Resolution: Fixed Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Team: Team D
Story Points: 0.25

 Description   

Using zabbix_utils Python library to add tag to a host "Testhost":

>>> from zabbix_utils import ZabbixAPI
>>> zapi = ZabbixAPI(url="https://zabbix.example.com/zabbix")
>>> zapi.login(token="xxxyyyzzz")
>>> zapi.version
7.0.4
>>> host = zapi.host.get(filter={"host":"Testhost"}, selectTags="extend")[0]
>>> tags = host["tags"]

# Existing tag:

>>> tags
[{'tag': 'tag1', 'value': 'value1', 'automatic': '0'}]
>>>

# Now add another tag:

>>> tags.append({"tag": "tag2", "value": "value2"})
>>> tags
[{'tag': 'tag1', 'value': 'value1', 'automatic': '0'}, {'tag': 'tag2', 'value': 'value2'}]
>>> zapi.host.update({"hostid": host["hostid"], "tags": tags})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/markku/temp/zabbix_utils/venv/lib/python3.11/site-packages/zabbix_utils/api.py", line 90, in func
    return self.parent.send_api_request(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/markku/temp/zabbix_utils/venv/lib/python3.11/site-packages/zabbix_utils/api.py", line 376, in send_api_request
    raise APIRequestError(err)
zabbix_utils.exceptions.APIRequestError: Invalid params. Invalid parameter "/1/tags/1": unexpected parameter "automatic".
>>>

Error message: Invalid params. Invalid parameter "/1/tags/1": unexpected parameter "automatic".

 

Workaround:

Remove the "automatic" values from the tag list before updating the host:

>>> for tag in tags:
...     tag.pop("automatic", None)
...
'0'
>>> tags
[{'tag': 'tag1', 'value': 'value1'}, {'tag': 'tag2', 'value': 'value2'}]
>>> zapi.host.update({"hostid": host["hostid"], "tags": tags})
{'hostids': ['12345']}
>>>


 Comments   
Comment by Markku Leiniö [ 2024 Oct 21 ]

About the presented workaround: I didn't test if Zabbix then would reset the "automatic" field value always to "0" if it was originally set to "1" for an existing tag ("tag created by low-level discovery") when updating the tag list.

Comment by Markku Leiniö [ 2024 Nov 06 ]

Note that this is not a Python-specific error (tested with 7.0.5):

[root@zabbix-srv ~]# curl -k -w "\n" -s -X POST -H 'Content-Type: application/json-rpc' -H 'Authorization: Bearer '$ZBXAPITOKEN'' -d '
{
    "jsonrpc": "2.0",
    "method": "host.get",
    "params": {
        "hostids": "10638", "output":[], "selectTags":"extend"
    },
    "id": 1
}
' https://zabbix-srv.zabbix.training/api_jsonrpc.php | jq
{
  "jsonrpc": "2.0",
  "result": [
    {
      "hostid": "10638",
      "tags": [
        {
          "tag": "location",
          "value": "Big City",
          "automatic": "0"
        },
        {
          "tag": "environment",
          "value": "production",
          "automatic": "0"
        }
      ]
    }
  ],
  "id": 1
}

[root@zabbix-srv ~]# curl -k -w "\n" -s -X POST -H 'Content-Type: application/json-rpc' -H 'Authorization: Bearer '$ZBXAPITOKEN'' -d '
{
    "jsonrpc": "2.0",
    "method": "host.update",
    "params": {
        "hostid": "10638", "tags":[
          {
            "tag": "location",
            "value": "Big City",
            "automatic": "0"
          },
          {
            "tag": "environment",
            "value": "production",
            "automatic": "0"
          },
          {
            "tag": "tag1",
            "value":"value1"
          }
        ]
    },
    "id": 1
}
' https://zabbix-srv.zabbix.training/api_jsonrpc.php | jq
{
  "jsonrpc": "2.0",
  "error": {
    "code": -32602,
    "message": "Invalid params.",
    "data": "Invalid parameter \"/1/tags/1\": unexpected parameter \"automatic\"."
  },
  "id": 1
}
 
Comment by Marianna Zvaigzne [ 2025 Feb 19 ]

Thank you for reporting! Documented in:

  • Host object > Host tag (7.0, 7.2, 7.4)
  • host.get > Searching by host tags (7.0, 7.2, 7.4)
Generated at Sat Jun 07 18:45:57 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.