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

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

Merged
merged 1 commit into from
Nov 14, 2024

Conversation

leventebalogh
Copy link
Collaborator

@leventebalogh leventebalogh commented Nov 14, 2024

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

✨ Test out this PR locally via:

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

@leventebalogh leventebalogh added create-plugin related to the create-plugin tool patch Increment the patch version when merged release Create a release when this pr is merged type/bug Something isn't working labels Nov 14, 2024
@leventebalogh leventebalogh self-assigned this Nov 14, 2024
@leventebalogh leventebalogh requested a review from a team as a code owner November 14, 2024 13:06
@leventebalogh leventebalogh requested review from Ukochka and removed request for a team November 14, 2024 13:06
Copy link

github-actions bot commented Nov 14, 2024

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.

@leventebalogh leventebalogh merged commit a1ed5cc into main Nov 14, 2024
14 checks passed
@leventebalogh leventebalogh deleted the leventebalogh/go-sdk-json-parsing branch November 14, 2024 15:47
@grafana-plugins-platform-bot
Copy link

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

@grafana-plugins-platform-bot grafana-plugins-platform-bot bot added the released This issue/pull request has been released. label Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
create-plugin related to the create-plugin tool patch Increment the patch version when merged release Create a release when this pr is merged released This issue/pull request has been released. type/bug Something isn't working
Projects
Status: 🚀 Shipped
Development

Successfully merging this pull request may close these issues.

2 participants