Skip to content

Error toast appears when fetching organizations without an active session #5104

@nikolay-1986

Description

@nikolay-1986

Summary

A user-facing error toast — "Unable to get organizations due to error: Error: Authentication required" — appears when GitLens fetches organizations in the background while no active authentication session exists. This is an expected condition (user not signed in), not an actionable error, and should not surface to the user.

Image

Impact

Any user without an active GitKraken session may see this unexpected error toast. The notification can also intercept pointer events in the editor until dismissed, causing secondary UX issues.

Root Cause

When the Home webview is open and the subscription state changes, SubscriptionService calls organizations.getOrganizations() to update the org count. If no authentication session is active, the request fails with AuthenticationRequiredError — an expected condition that is treated as a hard error and surfaced as a toast.

This is inconsistent with how the same error is handled elsewhere in the codebase (enrichmentService, draftsView, launchpadView), where AuthenticationRequiredError is caught and handled silently.

Additionally, the error message uses direct exception interpolation which, for certain AuthenticationError types, may expose token metadata (microHash, scopes, expiresAt) in the user-visible toast. The existing getPresentableErrorMessage helper should be used instead to safely format user-facing error strings.

Validation

  1. Open VS Code with GitLens
  2. Ensure no GitKraken account session is active
  3. Open the Home view
  4. Trigger any subscription state change
  5. Observe: "Unable to get organizations due to error: Error: Authentication required" toast appears (Source: GitLens — Git supercharged)

Expected: no toast for an unauthenticated background fetch; error logged at debug level only.

Risk

Low — affects only notification behavior for background fetches when unauthenticated. No functional change to organization loading or subscription state.

Gitlens Version

2026.4.220

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-pro-accountIssues or features related to Pro accounts

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions