Library Panel API strange behaviour

  • What Grafana version and what operating system are you using?
    v9.5.6
  • What are you trying to achieve?
    Update library panel using (/api/library-elements/) API
  • How are you trying to achieve it?
    curl -s -XPATCH
    -w ‘%{http_code}’
    –dump-header headers.txt
    -H “Authorization: Bearer $GRAFANA_API_TOKEN”
    -H ‘Content-Type: application/json’
    “$GRAFANA_URL/api/library-elements/$LIBRARY_PANEL_UID”
    -o update_result.json
    -d @updated_library_panel.json)
    where (updated_library_panel.json) is the panel Json im trying to update
  • What happened?
    when updating the panel, the query disappeared from the panel and it show me (none) on the panel result. the error i got is (D.query is not a function)
  • What did you expect to happen?
    i expect to have the same source panel since i took the query from it
  • Can you copy/paste the configuration(s) that you are having problems with?
    i generate (updated_library_panel.json) using the below code

import json

print("Building Library Panel json file ")
with open(‘current_library_panel.json’) as lib_json_file:
lib_panle_json_file = json.load(lib_json_file)
current_panel_version = lib_panle_json_file[‘result’][‘version’]

with open(‘payload.json’) as payload_json_file:
payload_file = json.load(payload_json_file)
for panels in payload_file[‘dashboard’][‘panels’]:
if ‘title’ in panels.keys() and panels[‘title’] == ‘XXXX’:
print(panels)
library_panel_json = {
“model”: panels,
“kind”: 1,
“version”: current_panel_version
}

with open(“updated_library_panel.json”, “w”) as output_file:
json.dump(library_panel_json, output_file)

Then i update the file panel using

curl -s -XPATCH
-w ‘%{http_code}’
–dump-header headers.txt
-H “Authorization: Bearer $GRAFANA_API_TOKEN”
-H ‘Content-Type: application/json’
“$GRAFANA_URL/api/library-elements/$LIBRARY_PANEL_UID”
-o update_result.json
-d @updated_library_panel.json)

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    No
  • Did you follow any online instructions? If so, what is the URL?
    No

Note im using grafana-lib to generate code, thats why i need the API to update the library panel

another note , that i noticed the some panels can be updated without any problem, and some other had a problem, which i cant know whats the issue(expect that im using transform heavily which it could be the porblem)