Skip to content

update_dashboard ignores folderUid in meta #214

@CantankerousBullMoose

Description

@CantankerousBullMoose

update_dashboard pulls the folderId out of the meta dictionary if it's not in the main dashboard payload, but it should be doing the same thing for the folderUid

To Reproduce
Steps to reproduce the behavior:

  1. Start with a folder that contains a dashboard
  2. folderDef = get_folder(
  3. dashboardDef = get_dashabord()
  4. delete_dashboard()
  5. delete_folder()
  6. create_folder(uid=folderDef['uid'], title=foldlerDef['title'])
  7. update_dashboard(dashboardDef)

I would expect the create_dashboard call in step 8 to transparently accept the dashboard payload I grabbed in step 3, but instead, there's an exception saying "folder not found" because the folder created in step 7 has the same UID as the original, but grafana auto-assigns the ID, and update_dashboard only looks at the dashboardDef['meta']['folderId'], ignoring dashboardDef['meta']['folderUid']. A workaround is to push the folderUid into the top level payload on my own, but I think it's reasonable to expect that reading a dashboard payload and then writing it again unmodified should work.

Versions

  • Grafana: 11.3
  • grafana-client: 4.3.0
  • Authentication: Basic

Additional context
This problem arises from trying to export dashboards and folders from an instance of Grafana, then import them into a different instance or the same instance that's been modified. The deletes in steps 3 and 4 represent a 'fresh' instance. I understand that these kinds of backup/restore/import/export usecases are a pretty common reason to use the client library, so I think it would be good if it worked intuitively in those cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions