Skip to content

Commit 69ec1ba

Browse files
committed
fix(grafana): reject invalid panels JSON instead of silently ignoring it
Grafana's dashboard API treats panels as a required array and returns 400 on invalid JSON; this route already errors on every other JSON param. Return 'Invalid JSON for panels parameter' instead of swallowing the parse error and proceeding with a misleading success.
1 parent b84f492 commit 69ec1ba

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

  • apps/sim/app/api/tools/grafana/update_dashboard

apps/sim/app/api/tools/grafana/update_dashboard/route.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,13 @@ export const POST = withRouteHandler(async (request: NextRequest) => {
116116
if (params.panels) {
117117
try {
118118
updatedDashboard.panels = JSON.parse(params.panels)
119-
} catch {}
119+
} catch {
120+
return NextResponse.json({
121+
success: false,
122+
output: {},
123+
error: 'Invalid JSON for panels parameter',
124+
})
125+
}
120126
}
121127

122128
if (existingDashboard.version) {

0 commit comments

Comments
 (0)