Skip to content

Conversation

Copy link

Copilot AI commented Oct 29, 2025

The token retriever already caches JWTs in sessionStorage and falls back to cache on HTTP errors, but not on network failures (fetch exceptions). This adds the same fallback behavior for network errors.

Changes

  • LtiTokenRetriever.jsx: Added cached token fallback in catch block

    } catch (error) {
      // Try to get cached JWT before failing
      const cachedJwt = loadJwt();
      if (cachedJwt) {
        handleJwt(cachedJwt, server);
        setState({ loading: false, error: null });
        return;
      }
      setState({ loading: false, error: error.message });
    }
  • LtiTokenRetriever.test.jsx: Added test coverage for network error fallback scenarios and improved test isolation with sessionStorage cleanup

Behavior

Cached tokens now serve as fallback for:

  • Non-200 HTTP responses (except 403) — already existed
  • Network errors (fetch failures) — new

Errors still display when no cached token exists.

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:

  • example.com
    • Triggering command: node (vitest 3) (dns block)
    • Triggering command: node (vitest 2) (dns block)

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

Original prompt

Update the token retriever to store the token in the browser and use that if the token can't be retrieved from the fetch call.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits October 29, 2025 15:53
Co-authored-by: buckett <5921+buckett@users.noreply.github.com>
Co-authored-by: buckett <5921+buckett@users.noreply.github.com>
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
4.4% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Copilot AI changed the title [WIP] Update token retriever to store token in browser Add cached token fallback for network errors in LtiTokenRetriever Oct 29, 2025
Copilot AI requested a review from buckett October 29, 2025 16:00
@buckett
Copy link
Member

buckett commented Oct 30, 2025

This is all wrong so closing.

@buckett buckett closed this Oct 30, 2025
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.

2 participants