Skip to content

Fix runtime crash when server returns undefined roles in auth context#2970

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-storybook-errors
Draft

Fix runtime crash when server returns undefined roles in auth context#2970
Copilot wants to merge 2 commits intomainfrom
copilot/fix-storybook-errors

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 31, 2026

Storybook (Chromatic build #6892) reported 24 component errors caused by a null-safety gap in the auth context: ctx.roles.forEach(...) throws when the /whoami response omits roles.

Changes

  • src/context/index.ts — Guard against null/undefined roles in createAuthorizer:

    // before
    ctx.roles.forEach((role) => { ... });
    // after
    (ctx.roles ?? []).forEach((role) => { ... });
  • src/components/Authentication/Kratos/KratosAuthContextProvider.tsx — Add an explicit !payload guard before accessing payload.user and calling createAuthorizer(payload), covering the edge case where isLoading is false but payload is still undefined (e.g. query not yet resolved):

    if (!payload) {
      return <FullPageSkeletonLoader />;
    }

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • fonts.googleapis.com
    • Triggering command: /home/REDACTED/.cache/ms-playwright/chromium_headless_shell-1208/chrome-headless-shell-linux64/chrome-headless-shell /home/REDACTED/.cache/ms-playwright/chromium_headless_shell-1208/chrome-headless-shell-linux64/chrome-headless-shell --disable-field-trial-config --disable-REDACTED-networking --disable-REDACTED-timer-throttling --disable-REDACTEDing-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-REDACTED-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=AvoidUnnecessaryBeforeUnloadCheckSync,BoundaryEventDispatchTracksNodeRemoval,DestroyProfileOnBrowserClose,DialMediaRouteProvider,GlobalMediaControls,HttpsUpgrades,LensOverlay,MediaRouter,PaintHolding,ThirdPartyStoragePartitioning,Transl tnet/tools/grep ate tories.tsx /usr/bin/grep grep (dns block)
  • storybook.js.org
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/flanksource-ui/flanksource-ui/node_modules/.bin/storybook build --output-dir /tmp/storybook-build (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node node_modules/.bin/storybook dev --port 6006 --no-open (dns block)
  • www.chromatic.com
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 31, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
aws-preview Ready Ready Preview Mar 31, 2026 10:09am
flanksource-ui Ready Ready Preview Mar 31, 2026 10:09am

Request Review

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI changed the title [WIP] Fix storybook errors Fix runtime crash when server returns undefined roles in auth context Mar 31, 2026
Copilot AI requested a review from moshloop March 31, 2026 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants