Hi, I think I found a bug with the Balena Device Tag API. If we update a tag using the PATCH HTTP method, it looks like all the tags on that device get set to the new value, instead of only updating the tag with the specified key.
Here’s a quick script that triggers the issue:
API_TOKEN=<YOUR_TOKEN>
DEVICE_ID=<YOUR_DEVICE_ID>
curl -X POST "https://api.balena-cloud.com/v4/device_tag" -H "Content-Type: application/json" -H "Authorization: Bearer ${API_TOKEN}" --data '{ "device": '${DEVICE_ID}', "tag_key": "tag1", "value": "value1" }'
curl -X POST "https://api.balena-cloud.com/v4/device_tag" -H "Content-Type: application/json" -H "Authorization: Bearer ${API_TOKEN}" --data '{ "device": '${DEVICE_ID}', "tag_key": "tag2", "value": "value2" }'
curl -X POST "https://api.balena-cloud.com/v4/device_tag" -H "Content-Type: application/json" -H "Authorization: Bearer ${API_TOKEN}" --data '{ "device": '${DEVICE_ID}', "tag_key": "tag3", "value": "value3" }'
curl -X PATCH "https://api.balena-cloud.com/v4/device_tag" -H "Content-Type: application/json" -H "Authorization: Bearer ${API_TOKEN}" --data '{ "device": '${DEVICE_ID}', "tag_key": "tag3", "value": "new_value3" }'