Skip to content

fix(powerbi): improve error handling for embed token retrieval#792

Open
rusko124 wants to merge 1 commit intomasterfrom
fix-power-bi-token-refresh-recovery
Open

fix(powerbi): improve error handling for embed token retrieval#792
rusko124 wants to merge 1 commit intomasterfrom
fix-power-bi-token-refresh-recovery

Conversation

@rusko124
Copy link
Copy Markdown
Contributor

@rusko124 rusko124 commented May 2, 2026

User description

Fixes T10507. Customer's Power BI capacity is paused outside business hours; players showed "Unable to load report" and stayed stuck until reboot.

Two surgical changes to static/js/main.js:

  • initTokenRefreshLoop no longer gives up after 7 errors — caps the backoff exponent at maxErrorStep so the loop keeps retrying every refresh interval forever.
  • getEmbedToken no longer renders the error UI itself. The initial-load path in initializePowerBI shows the error template; background refresh failures stay silent and leave the rendered iframe in place.

PR Type

Bug fix


Description

  • Preserve Power BI token refresh retries

  • Move error UI handling upstream

  • Show initial load status details


Diagram Walkthrough

flowchart LR
  token["getEmbedToken throws enriched error"]
  init["initializePowerBI handles initial fetch failure"]
  refresh["Refresh loop retries with capped backoff"]
  iframe["Existing embedded report stays visible"]

  token -- "caught during startup" --> init
  token -- "caught during refresh" --> refresh
  refresh -- "avoids replacing UI" --> iframe
Loading

File Walkthrough

Relevant files
Bug fix
main.js
Refine Power BI token error flow                                                 

edge-apps/powerbi/static/js/main.js

  • Stop rendering error UI inside getEmbedToken
  • Attach HTTP status to thrown token errors
  • Handle initial token failures in initializePowerBI
  • Keep refresh retries running with capped backoff
+20/-19 

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 2, 2026

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ No major issues detected

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 2, 2026

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Ensure meaningful thrown messages

detailedMessage can still be falsy or non-string when the error payload does not
contain an error field, which produces an empty or useless message in the UI.
Normalize it to a safe fallback before creating the Error so callers always receive
a readable message.

edge-apps/powerbi/static/js/main.js [80-82]

-const error = new Error(detailedMessage)
+const message =
+  typeof detailedMessage === 'string' && detailedMessage.trim()
+    ? detailedMessage
+    : 'Failed to get embed token.'
+const error = new Error(message)
 error.status = response.status
 throw error
Suggestion importance[1-10]: 5

__

Why: This is a valid robustness improvement because response.json()['error'] may be missing or non-string, which can leave error.message blank in showError. It does not affect the success path, but it improves the quality of failure reporting.

Low

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants