fix(grafana): show descriptive error when dashboard image fails to load#789
fix(grafana): show descriptive error when dashboard image fails to load#789nicomiguelino wants to merge 4 commits intomasterfrom
Conversation
- Change fetchAndRenderDashboard return type from boolean to FetchResult discriminated union - Include HTTP status code and status text in the error message - Note that Screenly Anywhere and the Grafana Image Renderer plugin are required - Add tests for fetchAndRenderDashboard success, HTTP error, and network error paths - Flatten top-level describe blocks to stay within max-lines-per-function lint limit
PR Reviewer Guide 🔍(Review updated until commit 51a4008)Here are some key observations to aid the review process:
|
There was a problem hiding this comment.
Pull request overview
This PR improves error reporting for the Grafana edge-app when the dashboard image fetch/render fails, enabling more descriptive failures to be surfaced to users (and covered by unit tests).
Changes:
- Change
fetchAndRenderDashboardto return aFetchResultdiscriminated union instead ofboolean. - Surface HTTP/network error detail in the error thrown during initial load.
- Add unit tests for success, HTTP failure, and network failure paths.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
edge-apps/grafana/src/render.ts |
Introduces FetchResult and returns structured failure details from fetchAndRenderDashboard. |
edge-apps/grafana/src/main.ts |
Uses FetchResult to throw a more descriptive error when initial dashboard image load fails. |
edge-apps/grafana/src/main.test.ts |
Adds unit tests covering fetchAndRenderDashboard outcomes and refactors existing URL tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
PR Code Suggestions ✨Latest suggestions up to 51a4008
Previous suggestionsSuggestions up to commit ab95ed3
|
- Remove inaccurate plugin and Anywhere note from the error message - Add error overlay screenshots for 1920x1080 and 1080x1920 - Refactor e2e spec into a shared runScreenshotTest helper to eliminate duplication
- Revoke the previous blob URL before replacing it on each dashboard refresh - Restore globalThis.fetch and URL globals in afterEach to prevent test-order dependencies - Extract RENDER_URL and TOKEN constants and mockSuccessfulFetch helper to remove duplication - Add test for blob URL revocation - Add eslint-disable comment for max-lines-per-function on fetchAndRenderDashboard suite
|
Persistent review updated to latest commit 51a4008 |
- Remove FetchResult type and try-catch from fetchAndRenderDashboard - Throw with HTTP status and response body for richer error detail - Simplify main.ts to await the fetch directly; errors bubble to panic-overlay - Add mockFailedFetch helper in tests and assert on thrown errors - Add test for response body inclusion in the error message - Use plain text body in display-errors e2e mock for readable overlay - Regenerate display-errors screenshots
User description
Closes #787
Summary
FetchResultdiscriminated union fromfetchAndRenderDashboardinstead of a plain boolean, carrying the HTTP status and error messagePR Type
Bug fix, Tests
Description
Return structured Grafana fetch failure details
Show descriptive dashboard image load errors
Revoke old blob URLs on refresh
Cover success and failure test paths
Diagram Walkthrough
File Walkthrough
screenshots.spec.ts
Refactor screenshot tests and error statesedge-apps/grafana/e2e/screenshots.spec.ts
display_errorsScreenly mock variantrunScreenshotTestsetup helpermain.test.ts
Expand render fetch unit test coverageedge-apps/grafana/src/main.test.ts
fetchAndRenderDashboardafterEachmain.ts
Surface detailed dashboard load failuresedge-apps/grafana/src/main.ts
fetchAndRenderDashboardrender.ts
Return structured fetch results safelyedge-apps/grafana/src/render.ts
FetchResultdiscriminated union