Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle panic gracefully when passing JSON as string in the spec #208

Closed
basvdl opened this issue Mar 18, 2022 · 0 comments · Fixed by #327
Closed

Handle panic gracefully when passing JSON as string in the spec #208

basvdl opened this issue Mar 18, 2022 · 0 comments · Fixed by #327
Assignees

Comments

@basvdl
Copy link

basvdl commented Mar 18, 2022

As a first time user I was a bit puzzled how to add JSON to the spec when creating a dashboard. My first attempt was passing the JSON as string, resulting in a panic.

Can we handle the panic more gracefully and as bonus, add an example to the docs.

./grr-darwin-amd64 apply gel-dashboards.yaml
panic: interface conversion: interface {} is string, not map[string]interface {}

goroutine 1 [running]:
github.com/grafana/grizzly/pkg/grizzly.(*Resource).SetSpecString(...)
	/drone/src/pkg/grizzly/providers.go:90
...
github.com/go-clix/cli.(*Command).Execute(0xc0002c72c0, 0xc0008dff28, 0xa)
	/go/pkg/mod/github.com/go-clix/cli@v0.2.0/command.go:76 +0x105
main.main()
	/drone/src/cmd/grr/main.go:44 +0x26b

Content of gel-dashboards.yaml

apiVersion: grizzly.grafana.com/v1alpha1
kind: Dashboard
metadata:
    name: loki-writes
    folder: gel-system-monitoring
spec: |
  {
    "timezone": "utc",
    "title": "Loki / Writes",
    "uid": "writes",
    "version": 0
  }
@julienduchesne julienduchesne self-assigned this Feb 2, 2024
julienduchesne added a commit that referenced this issue Feb 2, 2024
Closes #208
The issue mentions that we should fail gracefully, but actually accepting a JSON spec seems like a good option to me
julienduchesne added a commit that referenced this issue Feb 2, 2024
Closes #208
The issue mentions that we should fail gracefully, but actually accepting a JSON spec seems like a good option to me
julienduchesne added a commit that referenced this issue Feb 5, 2024
Closes #208
The issue mentions that we should fail gracefully, but actually accepting a JSON spec seems like a good option to me
julienduchesne added a commit that referenced this issue Feb 5, 2024
* Support JSON string in `spec`
Closes #208
The issue mentions that we should fail gracefully, but actually accepting a JSON spec seems like a good option to me

* Deny strings instead of parsing the field as JSON
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 a pull request may close this issue.

2 participants