Skip to content

Conversation

@leeyikjiun
Copy link
Contributor

Summary

Fix JSON unmarshaling error when deploying Grafana dashboards due to Folder.ID type mismatch.

Problem

Grafana's API returns -1 for folder IDs in certain cases (e.g., with nested folders feature enabled in Grafana 11.6+). The previous uint type cannot represent negative values, causing deployment to fail with:

Error: failed to deploy dashboard: could not find or create folder: error making API request: json: cannot unmarshal number -1 into Go struct field Folder.id of type uint

Solution

Changed Folder.ID from uint to int64 to match Grafana's official Go client:
https://github.com/grafana/grafana-api-golang-client/blob/master/folder.go

type Folder struct {
    ID    int64  `json:"id"`
    UID   string `json:"uid"`
    Title string `json:"title"`
    URL   string `json:"url"`
}

Testing

  • Verified dashboard deployment succeeds after the fix
  • The change is backwards compatible (positive IDs work the same)

Grafana's API returns -1 for folder IDs in certain cases (e.g., nested
folders feature). The previous uint type cannot represent negative
values, causing JSON unmarshaling to fail.

Changed to int64 to match Grafana's official Go client:
https://github.com/grafana/grafana-api-golang-client/blob/master/folder.go
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a JSON unmarshaling error during Grafana dashboard deployment by changing the Folder.ID field type from uint to int64 to handle negative folder IDs returned by Grafana's API.

Changes:

  • Updated Folder.ID type from uint to int64 to align with Grafana's official Go client
  • Added inline comment explaining the rationale for using int64

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link

github-actions bot commented Jan 23, 2026

✅ API Diff Results - No breaking changes


📄 View full apidiff report

@leeyikjiun leeyikjiun marked this pull request as ready for review January 23, 2026 07:41
@leeyikjiun leeyikjiun requested a review from a team as a code owner January 23, 2026 07:41
@ibrajer ibrajer added this pull request to the merge queue Jan 23, 2026
Merged via the queue into main with commit 3b25363 Jan 23, 2026
37 checks passed
@ibrajer ibrajer deleted the fix/observability-lib-folder-id-type branch January 23, 2026 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants