grafana / plugin-tools

Create Grafana plugins with ease.
https://grafana.com/developers/plugin-tools/
Apache License 2.0
58 stars 32 forks source link

Create Plugin: Add error-handling for JSON parsing in utils #1323

Closed leventebalogh closed 1 week ago

leventebalogh commented 1 week ago

What's the problem?

We received an error that happens when the return value of the go sdk version check command cannot be parsed as a JSON:

› npx @grafana/create-plugin@latest update
undefined:1

SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at file:///Users/l2d2/.npm/_npx/c8ca622b04c0c218/node_modules/@grafana/create-plugin/dist/utils/utils.goSdk.js:58:34
    at ChildProcess.exithandler (node:child_process:430:5)
    at ChildProcess.emit (node:events:514:28)
    at maybeClose (node:internal/child_process:1105:16)
    at Socket.<anonymous> (node:internal/child_process:457:11)
    at Socket.emit (node:events:514:28)
    at Pipe.<anonymous> (node:net:337:12)

What changed?

This PR adds a simple error handling for the JSON parsing, so it fails gracefully in case the return value is not a valid JSON.

📦 Published PR as canary version: Canary Versions
:sparkles: Test out this PR locally via: ```bash npm install @grafana/create-plugin@5.9.2-canary.1323.45d3ff8.0 # or yarn add @grafana/create-plugin@5.9.2-canary.1323.45d3ff8.0 ```
github-actions[bot] commented 1 week ago

Hello! 👋 This repository uses Auto for releasing packages using PR labels.

✨ This PR can be merged and will trigger a new patch release. NOTE: When merging a PR with the release label please avoid merging another PR. For further information see here.

grafana-plugins-platform-bot[bot] commented 1 week ago

:rocket: PR was released in @grafana/create-plugin@5.9.2, @grafana/plugin-e2e@1.12.1 :rocket: